diff --git a/basic/test.bsc b/basic/test.bsc index c8e2431e..25fd13ce 100644 --- a/basic/test.bsc +++ b/basic/test.bsc @@ -1,21 +1,22 @@ -renumber -cls -list -' "Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -' "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -' "Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -print "abcdefghi" -a -b -c -d -e -f -g -h -i -j -k -l -m -n +cls:gload "graphics.gfx" +mem = alloc(8*6+3):rect solid ink 4 from 0,0 to 319,239 +poke mem,1:poke mem+1,8:poke mem+2,6 +for y = 0 to 5 + base = (y & 1) * $F0 + for x = 0 to 7 + poke x+y*8+mem+3,base+x + next +next +tilemap mem,0,0 +call draw(10,10) +end +call draw(114,183) +call draw(250,-8) +call draw(-11,109) +end + + +proc draw(x,y) + s = 1 + tiledraw x,y dim s to x+8*s*16,y+6*s*16 +endproc \ No newline at end of file diff --git a/documents/TODO b/documents/TODO index b5660971..f675e651 100644 --- a/documents/TODO +++ b/documents/TODO @@ -17,10 +17,10 @@ General Larger Additions ---------------- + - Complete 32x32 tiles (scaled) + - Reference Parameters - - 32x32 tiles (scaled) - - Merge CPM65 PR - Cat Wildcard (post Merge ?) @@ -28,7 +28,6 @@ Larger Additions - Serial uploading - save to storage option. - - Sprites - something like AMAL - write spec document, probably bytecode diff --git a/documents/release/Changelog.txt b/documents/release/Changelog.txt index 2d2e2eee..c14cdd8a 100644 --- a/documents/release/Changelog.txt +++ b/documents/release/Changelog.txt @@ -136,4 +136,5 @@ Changes IMP: Insert and Delete work, Backspace works properly. IMP: Added DELETE command IMP: Added RENUMBER command + BRK: The size is now passed via DIM in the TILEDRAW not TILEMAP. \ No newline at end of file diff --git a/documents/release/api.odt b/documents/release/api.odt index f19a8bcb..256b68fd 100644 Binary files a/documents/release/api.odt and b/documents/release/api.odt differ diff --git a/firmware/common/include/interface/graphics.h b/firmware/common/include/interface/graphics.h index 7f785b06..f6cbf796 100644 --- a/firmware/common/include/interface/graphics.h +++ b/firmware/common/include/interface/graphics.h @@ -47,6 +47,7 @@ void GFXPlotPixel(struct GraphicsMode *gMode,int x,int y); void GFXPlotPixelChecked(struct GraphicsMode *gMode,int x,int y); void GFXEllipse(struct GraphicsMode *gMode,int x1,int y1,int x2,int y2,int useSolidFill); int GFXFindImage(int type,int id); +uint8_t GFXGetDrawSize(void); #endif diff --git a/firmware/common/sources/interface/gfxcommands.cpp b/firmware/common/sources/interface/gfxcommands.cpp index 3a573dfa..ac567de7 100644 --- a/firmware/common/sources/interface/gfxcommands.cpp +++ b/firmware/common/sources/interface/gfxcommands.cpp @@ -51,6 +51,16 @@ void GFXSetDefaults(uint8_t *cmd) { flipBits = cmd[8]; } +// *************************************************************************************** +// +// Accessor for draw size +// +// *************************************************************************************** + +uint8_t GFXGetDrawSize(void) { + return drawSize; +} + // *************************************************************************************** // // Draw a pixel diff --git a/firmware/common/sources/interface/tilemap.cpp b/firmware/common/sources/interface/tilemap.cpp index 6e008e04..f40ddb96 100644 --- a/firmware/common/sources/interface/tilemap.cpp +++ b/firmware/common/sources/interface/tilemap.cpp @@ -20,6 +20,8 @@ static uint8_t *gDraw; // Draw from here. static uint8_t *tilePtr; // Tile data from here. static uint8_t *tilePixels; // Tile pixel data. static uint16_t yTile; // Tracking tile draw position. +static uint8_t tileSize; // Tile Size = 16 or 32 +static uint8_t tileShift; // Tile shift to divide (4 or 5) static void TMRRenderTileLine(uint8_t count); static void TMRenderTileLineStart(uint8_t count); @@ -45,11 +47,17 @@ void TMPSelectTileMap(uint8_t *data,uint16_t xOffset,uint16_t yOffset) { // *************************************************************************************** uint8_t TMPDrawTileMap(uint8_t *data) { + int xPos = xTilePos,yPos = yTilePos; + tileSize = 16;tileShift = 4; // Work out size and shift + if (GFXGetDrawSize() == 2) { + tileSize = 32;tileShift = 5; + } + if (mapData == NULL) return 1; // No map specified. if (xPos < 0 || yPos < 0 || // Invalid draw position. - xPos >= width * 16 || yPos >= height * 16) return 1; + xPos >= width * tileSize || yPos >= height * tileSize) return 1; int16_t x1 = data[4]+(data[5] << 8); // Parameters. int16_t y1 = data[6]+(data[7] << 8); @@ -58,7 +66,7 @@ uint8_t TMPDrawTileMap(uint8_t *data) { xWindow = (x1 < x2) ? x1 : x2;yWindow = (y1 < y2) ? y1 : y2; // Work out drawing window wWindow = abs(x1-x2);hWindow = abs(y1-y2); - if (wWindow < 16) return 1; // Reject this special case. + if (wWindow < tileSize) return 1; // Reject this special case. if (xWindow < 0) { // Adjust for off left xPos += abs(xWindow); @@ -84,22 +92,22 @@ uint8_t TMPDrawTileMap(uint8_t *data) { int xLeader,xBlock16,xTrailer; int todo = wWindow; // Pixels horizontally - if (xPos+wWindow >= width * 16) todo = width*16-xPos; // Trim to right side - xLeader = (-xPos & 15); // Pixels to display to first whole tile. - xBlock16 = (todo - xLeader) / 16; // Number of whole tiles to display - xTrailer = todo - xLeader - xBlock16 * 16; // Pixels to display to edge. + if (xPos+wWindow >= width * tileSize) todo = width*tileSize-xPos; // Trim to right side + xLeader = (-xPos & (tileSize-1)); // Pixels to display to first whole tile. + xBlock16 = (todo - xLeader) / tileSize; // Number of whole tiles to display + xTrailer = todo - xLeader - xBlock16 * tileSize; // Pixels to display to edge. gDraw = gMode.graphicsMemory + x + yWindow * gMode.xGSize; // Start drawing here. // printf("TD:%d,%d %d,%d\n",xWindow,yWindow,wWindow,hWindow); // printf("%d %d %d\n",xLeader,xBlock16,xTrailer); - while (lineCount > 0 && yTile < height * 16) { // Until complete or off tile map - tilePtr = mapData + 3 + (yTile >> 4) * width + (xPos >> 4); // Tile data comes from here. + while (lineCount > 0 && yTile < height * tileSize) { // Until complete or off tile map + tilePtr = mapData + 3 + (yTile>>tileShift)*width+(xPos>>tileShift); // Tile data comes from here. uint8_t *gStart = gDraw; // Start of drawing. if (y >= 0 && y <= gMode.yGSize) { if (xLeader != 0) TMRenderTileLineStart(xLeader); // Do the first pixels. - for (int i = 0;i < xBlock16;i++) TMRRenderTileLine(16); // Render complete 16 pixel tiles. + for (int i = 0;i < xBlock16;i++) TMRRenderTileLine(tileSize); // Render complete 16 pixel tiles. if (xTrailer != 0) TMRRenderTileLine(xTrailer); // Do the last pixels. if (todo != wWindow) TMROutputBackground(wWindow-todo); // Any following blanks } @@ -107,7 +115,7 @@ uint8_t TMPDrawTileMap(uint8_t *data) { gDraw = gStart + gMode.xGSize; // Down on screen yTile++; // Next tile position } - while (lineCount-- > 0) { + while (lineCount-- > 0) { // Blank the bottom unused area to sprites only. for (uint16_t i = 0;i < wWindow;i++) { gDraw[i] &= 0xF0; } @@ -227,5 +235,6 @@ static void TMRenderTileLineStart(uint8_t count) { // Date Revision // ==== ======== // 28-01-24 Amended to allow tilemaps to overlap windows. +// 07-02-24 Started conversion to allow 32x32 tiles (scaled) // // ***************************************************************************************