From 945b68ce1ccd0e0f79a22ce9d583b014229a28a6 Mon Sep 17 00:00:00 2001 From: Cuptain Date: Fri, 30 Aug 2024 11:39:58 +1000 Subject: [PATCH] map display --- src/main.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index e42e390..2115d1c 100644 --- a/src/main.c +++ b/src/main.c @@ -4,16 +4,34 @@ Line l; -const u8[][] = [[1,1,1,1,1,1,1,1,1,1], - [1,0,0,0,0,0,0,0,0,1], - [1,1,1,1,0,0,1,1,1,1], - [1,0,0,1,0,0,1,0,0,1], - [1,0,0,0,0,0,1,0,0,1], - [1,0,0,1,0,0,1,1,0,1], - [1,1,1,1,0,0,1,0,0,1], - [1,0,0,0,0,0,0,0,0,1], - [1,0,0,0,0,0,1,0,0,1], - [1,1,1,1,1,1,1,1,1,1]]; +const u8 map[10][10] = {{1,1,1,1,1,1,1,1,1,1}, + {1,0,0,0,0,0,0,0,0,1}, + {1,1,1,1,0,0,1,1,1,1}, + {1,0,0,1,0,0,1,0,0,1}, + {1,0,0,0,0,0,1,0,0,1}, + {1,0,0,1,0,0,1,1,0,1}, + {1,1,1,1,0,0,1,0,0,1}, + {1,0,0,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,1,0,0,1}, + {1,1,1,1,1,1,1,1,1,1}}; + +void mapscan(){ + + u8 mapcolor = 14; + mapcolor |= mapcolor << 4; + int mapscale = 10; + + for(u8 x = 0; x < 10; x++){ + for(u8 y = 0; y < 10; y++){ + if(map[y][x] == 1){ + Vect2D_s16 mapverts[4] = {{x*mapscale,y*mapscale},{(x+1)*mapscale,y*mapscale},{(x+1)*mapscale,(y+1)*mapscale},{x*mapscale,(y+1)*mapscale}}; + BMP_drawPolygon(mapverts, 4, mapcolor); + + } + } + + } +} void render(){ @@ -23,6 +41,8 @@ void render(){ //Draw the line defined above (in the background, hidden) BMP_drawLine(&l); + mapscan(); + //Flip the data to the screen - i.e. actually draw the complete image on screen BMP_flip(1); @@ -70,7 +90,7 @@ int main() //Set the colour of the line. We are using pallete 0 for the bitmap, so we have 0->15. 15 is used for white text, so we set an unused pallet colour, 14 to blue - RGB 0000FF. u16 colour_blue = RGB24_TO_VDPCOLOR(0x0000ff); - u16 colour_red = RGB24_TO_VDPCOLOR(0xff0000); + u16 colour_red = RGB24_TO_VDPCOLOR(0x756a4a); PAL_setColor(14, colour_blue); PAL_setColor(13, colour_red); VDP_setBackgroundColor(13);