#include "../include/drawstuff.h" #include "../parameters.h" #include #include #include "../fixed.h" extern uint8_t minYRoad; void gint_dhline(int x1, int x2, int y, uint16_t color) { if((uint)y >= 224) return; if(x1 > x2) swap(x1, x2); if(x1 >= 396 || x2 < 0) return; if(x1 < 0) x1 = 0; if(x2 >= 396) x2 = 395; int offset = 396 * y; gint_vram[offset + x1] = color; gint_vram[offset + x2] = color; x1 = x1 + (x1 & 1); x2 = (x2 + 1) & ~1; uint32_t *start = (void *)(gint_vram + offset + x1); uint32_t *end = (void *)(gint_vram + offset + x2); uint32_t op = (color << 16) | color; while(end > start) *--end = op; }; void drawGrass( int y1, int y2, uint8_t R, uint8_t G, uint8_t B ) { uint16_t color = C_RGB(R,G,B); for (int y=y1; y<=y2; y++) gint_dhline( 0, SCREEN_WIDTH, y, color ); }; void drawGrass( int y1, int y2, uint16_t color ) { for (int y=y1; y<=y2; y++) gint_dhline( 0, SCREEN_WIDTH, y, color ); }; void drawPolygon( int x1min, int x1max, int y1, int x2min, int x2max, int y2, uint8_t R, uint8_t G, uint8_t B ) { uint16_t color = C_RGB(R,G,B); if (y1==y2) { gint_dhline( x1min, x1max, y1, color ); return; } fixed_t deltay = fdiv(fix(1), fix(y2-y1)); fixed_t xmin = fix(x1min); fixed_t xmax = fix(x1max); fixed_t dxmin = fix(x2min-x1min); fixed_t dxmax = fix(x2max-x1max); for (int y=y1; y<=y2; y++) { if (y>0 && y0 && y