fixed (sorta)
This commit is contained in:
parent
a8eb642e9b
commit
bf9f03c963
73
src/main.c
73
src/main.c
@ -152,20 +152,24 @@ void castRay(s16 angle, s16 column){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Wall height calcs
|
//Wall height calcs
|
||||||
fix16 wallHeightFix16 = fix16Div(FIX16(SCREEN_HEIGHT), (shortestDist + FIX16(1)));
|
fix16 wallHeightFix16 = fix16Div(FIX16(SCREEN_HEIGHT), (shortestDist + FIX16(1)));
|
||||||
wallHeightFix16 = fix16Mul(wallHeightFix16, WALL_HEIGHT_SCALE);
|
wallHeightFix16 = fix16Mul(wallHeightFix16, WALL_HEIGHT_SCALE);
|
||||||
int wallHeight = fix16ToInt(wallHeightFix16);
|
int wallHeight = fix16ToInt(wallHeightFix16);
|
||||||
int wallTop = (SCREEN_HEIGHT / 2) - (wallHeight / 2);
|
int wallTop = (SCREEN_HEIGHT / 2) - (wallHeight / 2);
|
||||||
int wallBottom = (SCREEN_HEIGHT / 2) + (wallHeight / 2);
|
int wallBottom = (SCREEN_HEIGHT / 2) + (wallHeight / 2);
|
||||||
if (wallTop < 0) wallTop = 0;
|
if (wallTop < 0) wallTop = 0;
|
||||||
if (wallBottom >= SCREEN_HEIGHT) wallBottom = SCREEN_HEIGHT - 1;
|
if (wallBottom >= SCREEN_HEIGHT) wallBottom = SCREEN_HEIGHT - 1;
|
||||||
u16 tileTop = wallTop / TILE_HEIGHT;
|
u16 tileTop = wallTop / TILE_HEIGHT;
|
||||||
u16 tileBottom = wallBottom / TILE_HEIGHT;
|
u16 tileBottom = wallBottom / TILE_HEIGHT;
|
||||||
u16 tileHeight = tileBottom - tileTop + 1;
|
u16 tileHeight = tileBottom - tileTop + 1;
|
||||||
for (int yTile = tileTop; yTile <= tileBottom; yTile++) {
|
for (int yTile = 0; yTile <= SCREEN_TILES_Y; yTile++) {
|
||||||
VDP_setTileMapXY(BG_B, TILE_ATTR_FULL(PAL1, 0, FALSE, FALSE, TILE_FILLED), column, yTile);
|
if(yTile >= tileTop && yTile <= tileBottom){
|
||||||
|
VDP_setTileMapXY(BG_B, TILE_ATTR_FULL(PAL1, 0, FALSE, FALSE, TILE_FILLED), column, yTile);
|
||||||
|
}else{
|
||||||
|
VDP_setTileMapXY(BG_B, TILE_ATTR_FULL(PAL1, 0, FALSE, FALSE, TILE_EMPTY), column, yTile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -204,6 +208,7 @@ void mapscan() {
|
|||||||
void clearScreenWithTile(u16 tileIndex) {
|
void clearScreenWithTile(u16 tileIndex) {
|
||||||
// Fill the entire screen with the background tile
|
// Fill the entire screen with the background tile
|
||||||
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL1, 0, FALSE, FALSE, tileIndex), 0, 0, SCREEN_TILES_X, SCREEN_TILES_Y);
|
VDP_fillTileMapRect(BG_A, TILE_ATTR_FULL(PAL1, 0, FALSE, FALSE, tileIndex), 0, 0, SCREEN_TILES_X, SCREEN_TILES_Y);
|
||||||
|
//VDP_fillTileMapRect(BG_B, TILE_ATTR_FULL(PAL1, 0, FALSE, FALSE, tileIndex), 0, 0, SCREEN_TILES_X, SCREEN_TILES_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawMap() {
|
void drawMap() {
|
||||||
@ -216,25 +221,31 @@ void drawMap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void render() {
|
void render() {
|
||||||
clearScreenWithTile(TILE_EMPTY);
|
clearScreenWithTile(TILE_EMPTY);
|
||||||
s16 castStart = angle - 20;
|
s16 castStart = angle - 20;
|
||||||
if(angle >= 360) angle = angle - 360;
|
if(angle >= 360) angle = angle - 360;
|
||||||
if(angle < 0) angle = 360 + angle;
|
if(angle < 0) angle = 360 + angle;
|
||||||
|
if(castStart >= 360) castStart = castStart - 360;
|
||||||
for(int i = 0; i < 40; i++){
|
if(castStart < 0) castStart = 360 + castStart;
|
||||||
castRay(castStart + i, i);
|
|
||||||
}
|
for(int i = 0; i < 40; i++){
|
||||||
//drawMap();
|
s16 cast = castStart+i;
|
||||||
VDP_setTextPlane(BG_B);
|
if(cast >= 360) cast = cast - 360;
|
||||||
VDP_setTextPalette(2);
|
if(cast < 0) cast = 360 + cast;
|
||||||
VDP_showFPS(1);
|
castRay(cast, i);
|
||||||
char debugCastText[20];
|
//VDP_waitVSync();
|
||||||
sprintf(debugCastText, "Cast: %d", castStart);
|
}
|
||||||
VDP_drawText(debugCastText, 20, 2);
|
//drawMap();
|
||||||
angle = angle + 1;
|
VDP_setTextPlane(BG_B);
|
||||||
|
VDP_setTextPalette(2);
|
||||||
|
VDP_showFPS(1);
|
||||||
SYS_doVBlankProcess();
|
char debugCastText[20];
|
||||||
|
sprintf(debugCastText, "Cast: %03d", castStart);
|
||||||
|
VDP_drawText(debugCastText, 20, 2);
|
||||||
|
angle = angle + 1;
|
||||||
|
|
||||||
|
|
||||||
|
SYS_doVBlankProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
|
Loading…
Reference in New Issue
Block a user