From 223499545aebf0aa7bbdb86de8c25b64ea2a56fa Mon Sep 17 00:00:00 2001 From: Nightwolf-47 <72660447+Nightwolf-47@users.noreply.github.com> Date: Tue, 13 Sep 2022 22:50:24 +0200 Subject: [PATCH] Update files to release 1.1 - Added fade-in and fade-out effects - Added new tile images - Improved the way palettes are handled by the game - Minor optimizations - Modified endgame message layout - Modified selector position offset - Modified variable type names in header files for consistency - Fixed an issue where loading a saved game doesn't properly set disqualified player colors - Fixed an issue where menu sprites don't disappear before starting a new game - Fixed grid rendering being visible for a split second --- .gitignore | 1 + res/graphics/borderh.png | Bin 168 -> 168 bytes res/graphics/borderv.png | Bin 168 -> 170 bytes res/graphics/tile.png | Bin 174 -> 141 bytes res/graphics/tile1.png | Bin 204 -> 209 bytes res/graphics/tile2.png | Bin 228 -> 232 bytes res/graphics/tile3.png | Bin 249 -> 256 bytes res/graphics/tile4.png | Bin 229 -> 234 bytes res/graphics/tileexp.png | Bin 216 -> 219 bytes res/resources.res | 6 +-- src/data.c | 25 +++++++++--- src/data.h | 2 + src/main.c | 3 +- src/save.h | 5 ++- src/states/game/gameai.c | 9 ++-- src/states/game/gameai.h | 5 ++- src/states/game/gamelogic.c | 26 ++++++++---- src/states/game/gamelogic.h | 58 ++++++++++++++------------ src/states/game/gamestate.c | 75 ++++++++++++++++++---------------- src/states/game/gamestate.h | 7 ++-- src/states/menu/menustate.c | 16 ++++---- src/states/menu/menustate.h | 5 ++- src/states/title/titlestate.c | 9 ++-- src/states/title/titlestate.h | 5 ++- 24 files changed, 149 insertions(+), 108 deletions(-) diff --git a/.gitignore b/.gitignore index f5f6afd..f5b9154 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ src/boot/ .archive/ .vscode/ res/resources.h +*.txt diff --git a/res/graphics/borderh.png b/res/graphics/borderh.png index b652c48dac87485feefc8086074aad4b7973fc9b..2a0e8110d35f1d1a645dfec75ce410bf3008361d 100644 GIT binary patch delta 58 zcmZ3%xPozl4zr7k%S3%e-v9r-K!`!H=ge;RiLnOK2@7NeT$mVGr!kzh>_2*v0SG)@ L{an^LB{Ts5kN*`i delta 58 zcmZ3%xPozl4s(Qx!9;yU-VZM-e*E$HaYNyM;a#?gu?ErsPE0&om>FiDVVpTfq^pJj O2s~Z=T-G@yGywpoBNem& diff --git a/res/graphics/borderv.png b/res/graphics/borderv.png index dff0d46c095fa7d32a3e1408b76a9f412c9a8b2a..4797337903b9708a48b0c43b2952c2ec89ab9f1c 100644 GIT binary patch delta 68 zcmZ3%xQcOt4zr7k%S3%e-v9r-K!`!H=ge;RiLn~00-i38Asp9}6M!IPfjuJw>lX&e TRre-MV*mnAS3j3^P6u=80Ua%nX+wG@pvywf+iF4}+(xpUXO@geCy)r5?xt delta 121 zcmeBWT*o*;!j*-Yfq_9NQsFd^G6?Vqag9(h05bpo|G#3viXRLaKNvi2sCam6`N6Q| zhr)y(9)B1zZZLREQ26ko;>RD4A2$@HalP!GXsMwo;_2cTB5^r6z=?_H)G-c&QwNVT ZGN`ATtLB;Q)CQW!;OXk;vd$@?2>`2-EqVX| diff --git a/res/graphics/tile1.png b/res/graphics/tile1.png index c3ec669fc7222f6d94a7c577e12431ffe9499d1d..b9c1ad44490486c7eed319a9ffac59250e57ec8d 100644 GIT binary patch delta 101 zcmV-r0Gj{I0nq`FDFy%l07OJYkuNF)(ee{GkzFWEH%UZ6R2b7^P(lDj24!P7Fr)=1 zG!(%x4Gj&3b3#=^!w{TMJe)Kn1JaTaMyI9G%+)ZCAQAuoC51T)z(N3A00000NkvXX Hu0mjf7f>GB delta 96 zcmV-m0H6QS0n7oADF#?1FaQ7mkuNF)mI~>MkzFW9GD$>1R2b7^P(lI>%Ekyl3r=V# zf@2yQ8Vu)zs)mLkIH7nrX-Ed7B_oVZOQV^qv2g%OD>}fZB9#&V0000MkzFWXN=ZaPR2b7^P(lI>%Ekylbxvp~ zhyfxQlubiJgN=>BB!hCOYG@cx0z?8ipMkzFWsUr9tkR2b8Jj?oE#FboAVi@^zk zlgM)cA^VSDUShEnNj@Gu3dhMdov3}c0>B4X^Z-t?Tv6<};)5H21pI<0cnbWcAU4$Q vRCC*c6{@J9ie9Lq0cgM{0gHyZikgB4OF}{Rj?5@w00000NkvXXu0mjf-2pfx diff --git a/res/graphics/tile4.png b/res/graphics/tile4.png index fd0c3eb80e7fe8638987bb368bc3390b91490bfc..aa2d1abfa04c0d0978b82964956bb490e4435949 100644 GIT binary patch delta 126 zcmV-^0D=GI0qOyeDFy%l07OJYkuNF)(ee{GkzFWdP)S5VR2b7^P(lDj24!P7Fhu8s zhJsi?638(P4GlIn29ZEcsA^~!Py$GTIH6!pC{|7yn3D!JAT1eWKw2`$=(IGD(LmA= guL}m+If6(405BOt++QMsG5`Po07*qoM6N<$g6JMkzFWYOG!jQR2b7^P(lI>%EkzQ&It_# zF+e1PvT0~&u(2_iWKa%O4GjZIfJh)G6wC?5%1Hxr(!d6!C4&qAl0c)=(m+OoNW3l> bOwIuSRKG=$($E~-00000NkvXXu0mjfo!BYw diff --git a/res/graphics/tileexp.png b/res/graphics/tileexp.png index 5bee490706193499e71d40093f51f290d5650bc3..bce7422554d3d87855232ef0559aaeb1fbc5c49e 100644 GIT binary patch delta 111 zcmV-#0FeLK0owtPDFy%l07OJYkuNF)jLf@7kzFWOK}keGR2b7^P(lDj24!P7Fr*Ua z|9=F>{{R2aaL)gK@BhO%_W$3#14%(R|K8qvkDY_848;IcqfsoSo__?9007;+Qp%SX Ryc7Tc002ovPDHLkV1gW6FR}mt delta 108 zcmV-y0F(dQ0oVbMDF#?1FaQ7mkuNF)%QQjskzFWLK1oDDR2b7^P(lI>%EkylCC>l< z2#)>#|DWNU|Nq|qhjHxxzk3Ik0(1Voz4snF2U!`40jNf!SW0F8Kmh;(a#VjLcEdLS O0000img = img; - vidimg->vPos = newVImagePos; - newVImagePos += img->tileset->numTile; + vidimg->vPos = curTileInd; + curTileInd += img->tileset->numTile; vImageCount++; return vidimg; } @@ -65,15 +65,28 @@ void changeState(enum States newState) { SYS_die("Invalid game state!"); } + switch(newState) + { + case ST_TITLESTATE: + PAL_setColors(0,palette_black,64,CPU); + break; + default: + PAL_fadeOut(0,63,10,FALSE); + break; + } if(states[currentState].stop) states[currentState].stop(); VDP_clearPlane(BG_A,TRUE); VDP_clearPlane(BG_B,TRUE); VDP_clearSprites(); SPR_defragVRAM(); + SPR_update(); vImageCount = 0; - newVImagePos = TILE_USERINDEX; + curTileInd = TILE_USERINDEX; currentState = newState; + memset(newPalette,0,sizeof(newPalette)); + newPalette[15] = RGB24_TO_VDPCOLOR(0xEEEEEE); if(states[currentState].init) states[currentState].init(); + PAL_fadeIn(0,63,newPalette,15,TRUE); } diff --git a/src/data.h b/src/data.h index 8f03f40..09067d1 100644 --- a/src/data.h +++ b/src/data.h @@ -61,6 +61,8 @@ extern struct KASettings settings; //Game settings, can be changed in main menu extern const char* versionStr; //Version string, shows up in About menu +extern u16 newPalette[64]; //New palette, has to be set in init() function of a given state + extern struct VidReservedImage vimages[VIMAGE_MAXCOUNT]; extern bool isDemoPlaying; diff --git a/src/main.c b/src/main.c index 0c4bb89..c553b95 100644 --- a/src/main.c +++ b/src/main.c @@ -3,11 +3,10 @@ #include "states/game/gamestate.h" #include "states/title/titlestate.h" #include "states/menu/menustate.h" -#include void joyEventHandler(u16 joy, u16 changed, u16 state) { - if(states[currentState].joyevent) + if(states[currentState].joyevent && !PAL_isDoingFade()) states[currentState].joyevent(joy,changed,state); } diff --git a/src/save.h b/src/save.h index 48c7fda..7aa3ea0 100644 --- a/src/save.h +++ b/src/save.h @@ -1,5 +1,6 @@ #ifndef SAVE_H_DEFINED #define SAVE_H_DEFINED +#include #define SETTINGS_SRAM_POS 1 #define SAVEDATA_SRAM_POS 11 @@ -15,11 +16,11 @@ void loadSRAM(void); void invalidateSRAM(void); //Load game data from SRAM -long loadGameData(void); +fix32 loadGameData(void); //Save game data to SRAM as KSF (KleleAtoms 1.3 save format) void saveGameData(void); -extern unsigned short saveValid; +extern bool saveValid; #endif //SAVE_H_DEFINED diff --git a/src/states/game/gameai.c b/src/states/game/gameai.c index ce68730..4714140 100644 --- a/src/states/game/gameai.c +++ b/src/states/game/gameai.c @@ -120,7 +120,8 @@ void aiGetSpecialTiles(int difficulty, s16 (*psptiles)[84], s16 (*ptiles)[84], s { for(int y=0; yplayerNum == curPlayer || curtile->playerNum == NOPLAYER) //Atom can be placed on that tile { bool isSpTile = FALSE; @@ -132,7 +133,7 @@ void aiGetSpecialTiles(int difficulty, s16 (*psptiles)[84], s16 (*ptiles)[84], s { if(aiCheckPreCrit(x,y)) //Tile is special if you and another player have near-critical atom tiles near each other { - if(curtile->atomCount == (critGrid[GXYIndex(x,y)]-1)) + if(curtile->atomCount == (critGrid[tileIndex]-1)) { sptiles[*pspcount] = PACKCoords(x,y); *pspcount += 1; @@ -156,7 +157,7 @@ void aiGetSpecialTiles(int difficulty, s16 (*psptiles)[84], s16 (*ptiles)[84], s } else if(aiCheckPreCrit(x,y)) //The same as in difficulty 2 { - if(atomcount == (critGrid[GXYIndex(x,y)]-1)) + if(atomcount == (critGrid[tileIndex]-1)) { sptiles[*pspcount] = PACKCoords(x,y); *pspcount += 1; @@ -170,7 +171,7 @@ void aiGetSpecialTiles(int difficulty, s16 (*psptiles)[84], s16 (*ptiles)[84], s } bool isAdvantage = FALSE; if(!isSpTile) //If a tile isn't special, check if you have an atom advantage over another player - isAdvantage = aiCheckAdvantage(x,y,(s16)(atomcount)-(s16)(critGrid[GXYIndex(x,y)])); + isAdvantage = aiCheckAdvantage(x,y,(s16)(atomcount)-(s16)(critGrid[tileIndex])); if(!tileAvoided && isCorner && (aicornercount == 0 || aiCornerCheck(x,y))) //Add the corner tile to the corner array { diff --git a/src/states/game/gameai.h b/src/states/game/gameai.h index d21878a..ffde7db 100644 --- a/src/states/game/gameai.h +++ b/src/states/game/gameai.h @@ -1,7 +1,8 @@ #ifndef GAMEAI_H_INCLUDED #define GAMEAI_H_INCLUDED +#include -extern unsigned short aiPlayerTab[4]; //If TRUE, player is AI-controlled +extern bool aiPlayerTab[4]; //If TRUE, player is AI-controlled extern int aiDifficulty[4]; //Array of AI difficulty (1-3) per player @@ -9,6 +10,6 @@ void ai_init(void); void ai_resetTime(void); -void ai_tryMove(long dt); +void ai_tryMove(fix32 dt); #endif //GAMEAI_H_INCLUDED diff --git a/src/states/game/gamelogic.c b/src/states/game/gamelogic.c index 7046e9d..05f23d0 100644 --- a/src/states/game/gamelogic.c +++ b/src/states/game/gamelogic.c @@ -60,17 +60,19 @@ const char* playerNames[4] = {"Red","Blue","Green","Yellow"}; bool logicEnd = FALSE; //If TRUE the game will end and it will wait for a button press -void logic_endMessage(char* msg) +const fix32 baseExplodeTime = FIX32(0.3); //Longest duration of explosion sprite being shown after atom explosion + +void logic_endMessage(const char* msg) { logicEnd = TRUE; VDP_clearText(5+8*curPlayer,3,1); VDP_clearText(8+8*curPlayer,3,1); VDP_clearText(0,5,40); VDP_clearTileMapRect(BG_B,1,0,40,6); - VDP_drawText(msg,20-(strlen(msg)>>1),1); - VDP_drawText("Press any button to go to menu",5,2); VDP_clearText(31,0,9); VDP_clearText(1,0,10); + VDP_drawText(msg,GETCENTERX(msg),0); + VDP_drawText("Press any button to go to menu",5,2); curPlayer = 0; } @@ -292,7 +294,7 @@ void explodeAtoms(u8 x, u8 y, s16 atplayer) explosionCount++; u16 index = GXYIndex(x,y); struct Tile* curTile = &grid.tiles[index]; - curTile->explodeTime = FIX32(0.3)/max(min(explosionCount,1000)/10,1); + curTile->explodeTime = baseExplodeTime/max(min(explosionCount,1000)/10,1); u8 extra = (u8)max(curTile->atomCount-critGrid[index],0); //Amount of atoms above critical amount curTile->atomCount = 0; curTile->playerNum = NOPLAYER; @@ -423,7 +425,7 @@ void logic_loadAll(u8 gridWidth, u8 gridHeight, u8 (*ppttab)[4]) } else //Player is not present, make their icon black (invisible) { - PAL_setColor((i*16)+6,RGB24_TO_VDPCOLOR(0x000000)); + newPalette[(i*16)+6] = RGB24_TO_VDPCOLOR(0x000000); } } if(curPlayer == NOPLAYER || playerCount < 2) @@ -488,9 +490,16 @@ void logic_fixLoadedData() } for(int i=0; i<4; i++) { - if(playerTab[i]==PTAB_NO) + switch(playerTab[i]) { - PAL_setColor((i*16)+6,RGB24_TO_VDPCOLOR(0x000000)); + case PTAB_NO: + newPalette[(i*16)+6] = RGB24_TO_VDPCOLOR(0x000000); + break; + case PTAB_LOST: + newPalette[(i*16)+6] = RGB24_TO_VDPCOLOR(0x808080); + break; + default: + break; } } animPlaying = FALSE; @@ -567,7 +576,8 @@ void logic_tick(fix32 dt) else if(asPos > 0) { int curAsPos = asPos; - for(int i=0; i> 4; s8 ttposy = atomStack[curAsPos-1] & 0xF; diff --git a/src/states/game/gamelogic.h b/src/states/game/gamelogic.h index 371dbb9..1f4b351 100644 --- a/src/states/game/gamelogic.h +++ b/src/states/game/gamelogic.h @@ -1,3 +1,7 @@ +#ifndef GAMELOGIC_H_INCLUDED +#define GAMELOGIC_H_INCLUDED +#include + #define GRIDSIZE 24 #define ATOMSPEED 30 @@ -16,22 +20,22 @@ struct Tile { - short playerNum; - unsigned char atomCount; - long explodeTime; //If > 0, explosion sprite will appear + s16 playerNum; + u8 atomCount; + fix32 explodeTime; //If > 0, explosion sprite will appear }; struct AtomPosition { - short destx; - short desty; + s16 destx; + s16 desty; }; struct KAExplodePos { - unsigned char x; - unsigned char y; - unsigned short willExplode; + u8 x; + u8 y; + bool willExplode; }; struct KAGrid @@ -43,60 +47,62 @@ struct KAGrid extern struct KAGrid grid; -extern unsigned char critGrid[84]; +extern u8 critGrid[84]; -extern unsigned short animPlaying; +extern bool animPlaying; -extern short curPlayer; +extern s16 curPlayer; extern int playerTab[4]; extern int playerAtoms[4]; -extern unsigned short playerMoved[4]; +extern bool playerMoved[4]; extern int playerCount; extern int startPlayers; -extern unsigned char* atomStack; +extern u8* atomStack; extern int asPos; extern struct KAExplodePos explodePos; -extern short playerWon; +extern s16 playerWon; extern int explosionCount; extern struct AtomPosition atompos[16]; -extern short atomposIndex; +extern s16 atomposIndex; -extern unsigned short logicEnd; +extern bool logicEnd; -extern short gridStartX; +extern s16 gridStartX; -extern short gridStartY; +extern s16 gridStartY; //End the current game with a message -void logic_endMessage(char* msg); +void logic_endMessage(const char* msg); -const char* logic_getPlayerName(short playerNum); +const char* logic_getPlayerName(s16 playerNum); -void logic_loadAll(unsigned char gridWidth, unsigned char gridHeight, unsigned char (*ppttab)[4]); +void logic_loadAll(u8 gridWidth, u8 gridHeight, u8 (*ppttab)[4]); void logic_fixLoadedData(void); -void logic_clickedTile(unsigned char tx, unsigned char ty, unsigned short isAI); +void logic_clickedTile(u8 tx, u8 ty, bool isAI); -void logic_tick(long dt); +void logic_tick(fix32 dt); -void logic_draw(long dt); +void logic_draw(fix32 dt); void logic_stop(void); -void drawTile(unsigned char x, unsigned char y, short playerNum, unsigned char atomCount); +void drawTile(u8 x, u8 y, s16 playerNum, u8 atomCount); //Convert grid tile position (x,y) to pixel position (pixelx,pixely) -void tileToPixels(unsigned char x, unsigned char y, short* pixelx, short* pixely); +void tileToPixels(u8 x, u8 y, s16* pixelx, s16* pixely); + +#endif //GAMELOGIC_H_INCLUDED diff --git a/src/states/game/gamestate.c b/src/states/game/gamestate.c index 13e9085..4c3e1bd 100644 --- a/src/states/game/gamestate.c +++ b/src/states/game/gamestate.c @@ -1,6 +1,5 @@ #include "gamestate.h" #include "../../data.h" -#include #include "../../../res/resources.h" #include "gamelogic.h" #include "../../save.h" @@ -34,64 +33,68 @@ extern bool aiPlayerTab[4]; void setupGamePalettes(bool oldColors) { //PAL0 (Red) - PAL_setColor(0, RGB24_TO_VDPCOLOR(0x000000)); - PAL_setColor(2, RGB24_TO_VDPCOLOR(0xEEEEEE)); - PAL_setColor(3, RGB24_TO_VDPCOLOR(0xA8A0A8)); + newPalette[0] = RGB24_TO_VDPCOLOR(0x000000); + newPalette[1] = RGB24_TO_VDPCOLOR(0x444444); + newPalette[2] = RGB24_TO_VDPCOLOR(0xEEEEEE); + newPalette[3] = RGB24_TO_VDPCOLOR(0xA8A0A8); if(oldColors) { - PAL_setColor(5, RGB24_TO_VDPCOLOR(0xF80048)); - PAL_setColor(6, RGB24_TO_VDPCOLOR(0xC82448)); + newPalette[5] = RGB24_TO_VDPCOLOR(0xF80048); + newPalette[6] = RGB24_TO_VDPCOLOR(0xC82448); } else { - PAL_setColor(5, RGB24_TO_VDPCOLOR(0xEE0000)); - PAL_setColor(6, RGB24_TO_VDPCOLOR(0xCC2200)); + newPalette[5] = RGB24_TO_VDPCOLOR(0xEE0000); + newPalette[6] = RGB24_TO_VDPCOLOR(0xCC2200); } - //PAL1 (Blue 18-22 + Explosion 29-31) - PAL_setColor(18, RGB24_TO_VDPCOLOR(0xEEEEEE)); - PAL_setColor(19, RGB24_TO_VDPCOLOR(0xA8A0A8)); + //PAL1 (Blue 17-22 + Explosion 29-31) + newPalette[17] = RGB24_TO_VDPCOLOR(0x444444); + newPalette[18] = RGB24_TO_VDPCOLOR(0xEEEEEE); + newPalette[19] = RGB24_TO_VDPCOLOR(0xA8A0A8); if(oldColors) { - PAL_setColor(21, RGB24_TO_VDPCOLOR(0x00B4F8)); - PAL_setColor(22, RGB24_TO_VDPCOLOR(0x2090F8)); + newPalette[21] = RGB24_TO_VDPCOLOR(0x00B4F8); + newPalette[22] = RGB24_TO_VDPCOLOR(0x2090F8); } else { - PAL_setColor(21, RGB24_TO_VDPCOLOR(0x0000EE)); - PAL_setColor(22, RGB24_TO_VDPCOLOR(0x0000CC)); + newPalette[21] = RGB24_TO_VDPCOLOR(0x0000EE); + newPalette[22] = RGB24_TO_VDPCOLOR(0x0000CC); } - PAL_setColor(29, RGB24_TO_VDPCOLOR(0xF8FC48)); - PAL_setColor(30, RGB24_TO_VDPCOLOR(0xF8D820)); - PAL_setColor(31, RGB24_TO_VDPCOLOR(0xD80020)); + newPalette[29] = RGB24_TO_VDPCOLOR(0xF8FC48); + newPalette[30] = RGB24_TO_VDPCOLOR(0xF8D820); + newPalette[31] = RGB24_TO_VDPCOLOR(0xD80020); //PAL2 (Green) - PAL_setColor(34, RGB24_TO_VDPCOLOR(0xEEEEEE)); - PAL_setColor(35, RGB24_TO_VDPCOLOR(0xA8A0A8)); + newPalette[33] = RGB24_TO_VDPCOLOR(0x444444); + newPalette[34] = RGB24_TO_VDPCOLOR(0xEEEEEE); + newPalette[35] = RGB24_TO_VDPCOLOR(0xA8A0A8); if(oldColors) { - PAL_setColor(37, RGB24_TO_VDPCOLOR(0x48FC00)); - PAL_setColor(38, RGB24_TO_VDPCOLOR(0x66CC22)); + newPalette[37] = RGB24_TO_VDPCOLOR(0x48FC00); + newPalette[38] = RGB24_TO_VDPCOLOR(0x66CC22); } else { - PAL_setColor(37, RGB24_TO_VDPCOLOR(0x00EE00)); - PAL_setColor(38, RGB24_TO_VDPCOLOR(0x00CC00)); + newPalette[37] = RGB24_TO_VDPCOLOR(0x00EE00); + newPalette[38] = RGB24_TO_VDPCOLOR(0x00CC00); } //PAL3 (Yellow) - PAL_setColor(50, RGB24_TO_VDPCOLOR(0xEEEEEE)); - PAL_setColor(51, RGB24_TO_VDPCOLOR(0xA8A0A8)); + newPalette[49] = RGB24_TO_VDPCOLOR(0x444444); + newPalette[50] = RGB24_TO_VDPCOLOR(0xEEEEEE); + newPalette[51] = RGB24_TO_VDPCOLOR(0xA8A0A8); if(oldColors) { - PAL_setColor(53, RGB24_TO_VDPCOLOR(0xF8FC48)); - PAL_setColor(54, RGB24_TO_VDPCOLOR(0xEECC44)); + newPalette[53] = RGB24_TO_VDPCOLOR(0xF8FC48); + newPalette[54] = RGB24_TO_VDPCOLOR(0xEECC44); } else { - PAL_setColor(53, RGB24_TO_VDPCOLOR(0xEECC00)); - PAL_setColor(54, RGB24_TO_VDPCOLOR(0xEEAA00)); + newPalette[53] = RGB24_TO_VDPCOLOR(0xEECC00); + newPalette[54] = RGB24_TO_VDPCOLOR(0xEEAA00); } } @@ -161,13 +164,13 @@ void gamePreDraw(bool drawgrid) drawTile(x,y,ttile->playerNum & 3,ttile->atomCount); } } - for(int x=0; ximg,TILE_ATTR_FULL(PAL0,0,FALSE,FALSE,vidImgBorderH->vPos),(x*3)+gridStartX,(grid.height*3)+gridStartY,FALSE,TRUE); + VDP_drawImageEx(BG_B,vidImgBorderH->img,TILE_ATTR_FULL(PAL0,0,FALSE,FALSE,vidImgBorderH->vPos),(x*3)+gridStartX,gridStartY-1,FALSE,TRUE); } - for(int y=0; yimg,TILE_ATTR_FULL(PAL0,0,FALSE,FALSE,vidImgBorderV->vPos),(grid.width*3)+gridStartX,(y*3)+gridStartY,FALSE,TRUE); + VDP_drawImageEx(BG_B,vidImgBorderV->img,TILE_ATTR_FULL(PAL0,0,FALSE,FALSE,vidImgBorderV->vPos),gridStartX-1,(y*3)+gridStartY,FALSE,TRUE); } } @@ -267,7 +270,7 @@ void gamestate_update(fix32 dt) SPR_setVisibility(selector,AUTO_FAST); s16 px,py; tileToPixels(selectx,selecty,&px,&py); - SPR_setPosition(selector,px-4,py-4); //Update selection box position + SPR_setPosition(selector,px-5,py-5); //Update selection box position if(!logicEnd) { if(playerWon<0) //No player has won yet, proceed as normal @@ -311,7 +314,7 @@ void gamestate_update(fix32 dt) s16 seconds = dresult >> 16; char timebuf[16]; sprintf(timebuf,"Time: %02d:%02d",minutes,seconds); - VDP_drawText(timebuf,20-(strlen(timebuf)>>1),3); + VDP_drawText(timebuf,20-(strlen(timebuf)>>1),4); } } logic_draw(dt); diff --git a/src/states/game/gamestate.h b/src/states/game/gamestate.h index b337dd1..f87fcd8 100644 --- a/src/states/game/gamestate.h +++ b/src/states/game/gamestate.h @@ -1,14 +1,15 @@ #ifndef GAMESTATE_H_INCLUDED #define GAMESTATE_H_INCLUDED +#include void gamestate_init(void); -void gamestate_update(long dt); +void gamestate_update(fix32 dt); -void gamestate_joyevent(unsigned short joy, unsigned short changed, unsigned short state); +void gamestate_joyevent(u16 joy, u16 changed, u16 state); void gamestate_stop(void); -extern long startTime; //In-game timer +extern fix32 startTime; //In-game timer #endif //GAMESTATE_H_INCLUDED diff --git a/src/states/menu/menustate.c b/src/states/menu/menustate.c index 8859d11..464adb6 100644 --- a/src/states/menu/menustate.c +++ b/src/states/menu/menustate.c @@ -51,18 +51,19 @@ const char* ptnames[5] = { //Player type names void setupMenuPalette(bool oldColors) { - PAL_setColor(0, RGB24_TO_VDPCOLOR(0x002266)); - PAL_setColor(2, RGB24_TO_VDPCOLOR(0xEEEEEE)); + newPalette[0] = RGB24_TO_VDPCOLOR(0x002266); + newPalette[2] = RGB24_TO_VDPCOLOR(0xEEEEEE); if(oldColors) { - PAL_setColor(5, RGB24_TO_VDPCOLOR(0xF80048)); - PAL_setColor(6, RGB24_TO_VDPCOLOR(0xC82448)); + newPalette[5] = RGB24_TO_VDPCOLOR(0xF80048); + newPalette[6] = RGB24_TO_VDPCOLOR(0xC82448); } else { - PAL_setColor(5, RGB24_TO_VDPCOLOR(0xEE0000)); - PAL_setColor(6, RGB24_TO_VDPCOLOR(0xCC2200)); + newPalette[5] = RGB24_TO_VDPCOLOR(0xEE0000); + newPalette[6] = RGB24_TO_VDPCOLOR(0xCC2200); } + memcpy(&newPalette[16],menuBackground->palette->data,sizeof(u16)*menuBackground->palette->length); } //Wrap around the menu selection if needed and play sound @@ -232,6 +233,7 @@ void menuOptionAction(enum ActionType at) case 7: settings.useOldColors = !settings.useOldColors; setupMenuPalette(settings.useOldColors); + PAL_setColors(0,newPalette,64,CPU); break; case 8: settings.isHotSeat = !settings.isHotSeat; @@ -241,6 +243,7 @@ void menuOptionAction(enum ActionType at) { data_reset(); setupMenuPalette(settings.useOldColors); + PAL_setColors(0,newPalette,64,CPU); drawMenu(); } else @@ -278,7 +281,6 @@ void menustate_init(void) menuBackground = unpackImage(&texMenuBG,NULL); setupMenuPalette(settings.useOldColors); loadSRAM(); //Load settings and savegame (if exists) - PAL_setPalette(PAL1,menuBackground->palette->data,DMA); VDP_drawImageEx(BG_B,menuBackground,TILE_ATTR_FULL(PAL1,FALSE,FALSE,FALSE,TILE_USERINDEX),0,0,FALSE,TRUE); isAboutPage = FALSE; drawMenu(); diff --git a/src/states/menu/menustate.h b/src/states/menu/menustate.h index 7128c7a..3a6b51b 100644 --- a/src/states/menu/menustate.h +++ b/src/states/menu/menustate.h @@ -1,11 +1,12 @@ #ifndef MENUSTATE_H_INCLUDED #define MENUSTATE_H_INCLUDED +#include void menustate_init(void); -void menustate_update(long dt); +void menustate_update(fix32 dt); -void menustate_joyevent(unsigned short joy, unsigned short changed, unsigned short state); +void menustate_joyevent(u16 joy, u16 changed, u16 state); void menustate_stop(void); diff --git a/src/states/title/titlestate.c b/src/states/title/titlestate.c index 26fa1a9..b00a432 100644 --- a/src/states/title/titlestate.c +++ b/src/states/title/titlestate.c @@ -22,10 +22,10 @@ void titlestate_init(void) } vidImgTTS[0] = reserveVImage(titleScreen[0]); vidImgTTS[1] = reserveVImage(titleScreen[1]); - PAL_setColor(47,RGB24_TO_VDPCOLOR(0xEEEEEE)); VDP_setTextPalette(PAL2); - PAL_setPalette(PAL0,titleScreen[0]->palette->data,DMA); - PAL_setPalette(PAL1,titleScreen[1]->palette->data,DMA); + memcpy(newPalette,titleScreen[0]->palette->data,sizeof(u16)*titleScreen[0]->palette->length); + memcpy(&newPalette[16],titleScreen[1]->palette->data,sizeof(u16)*titleScreen[1]->palette->length); + newPalette[47] = RGB24_TO_VDPCOLOR(0xEEEEEE); VDP_drawImageEx(BG_B,vidImgTTS[0]->img,TILE_ATTR_FULL(PAL0,0,FALSE,FALSE,vidImgTTS[0]->vPos),0,0,FALSE,TRUE); VDP_drawImageEx(BG_B,vidImgTTS[1]->img,TILE_ATTR_FULL(PAL1,0,FALSE,FALSE,vidImgTTS[1]->vPos),26,0,FALSE,TRUE); VDP_drawText("Press any button to continue",2,5); @@ -59,7 +59,6 @@ void titlestate_stop(void) titleScreen[i] = NULL; } } - //Change text color palette back to PAL0 and set text color + //Change text color palette back to PAL0 VDP_setTextPalette(PAL0); - PAL_setColor(15,RGB24_TO_VDPCOLOR(0xEEEEEE)); } diff --git a/src/states/title/titlestate.h b/src/states/title/titlestate.h index 3ca4e4a..37fe5c8 100644 --- a/src/states/title/titlestate.h +++ b/src/states/title/titlestate.h @@ -1,11 +1,12 @@ #ifndef TITLESTATE_H_INCLUDED #define TITLESTATE_H_INCLUDED +#include void titlestate_init(void); -void titlestate_joyevent(unsigned short joy, unsigned short changed, unsigned short state); +void titlestate_joyevent(u16 joy, u16 changed, u16 state); -void titlestate_update(long dt); +void titlestate_update(fix32 dt); void titlestate_stop(void);