From 16e537729888445d48831e6f9d61376d9a50613f Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 15 May 2022 16:38:01 -0700 Subject: [PATCH] hate --- assets/images/card_back_small.png | Bin 0 -> 178 bytes assets/images/card_back_small.pxo | Bin 0 -> 423 bytes src/conversation/items/gameintro.c | 3 ++- src/conversation/queue.c | 2 +- src/drawing/playerchips.c | 19 +++++++++++++++ src/drawing/playerchips.h | 15 ++++++++++++ src/drawing/playerdeal.c | 15 ++++++++++++ src/drawing/playerdeal.h | 16 +++++++++++++ src/interrupts.c | 1 + src/main.c | 32 +++++++++++++------------- src/sprites/cards/spritecardscommon.h | 1 + src/sprites/spritecardsmall.c | 13 +++++++++++ src/sprites/spritecardsmall.h | 19 +++++++++++++++ src/sprites/spritefont.c | 12 ++++++++++ src/sprites/spritefont.h | 12 +++++++++- src/sprites/sprites.c | 4 ++++ src/sprites/sprites.h | 4 +++- src/strings.c | 13 ++++------- src/strings.h | 11 ++++----- 19 files changed, 156 insertions(+), 36 deletions(-) create mode 100644 assets/images/card_back_small.png create mode 100644 assets/images/card_back_small.pxo create mode 100644 src/drawing/playerchips.c create mode 100644 src/drawing/playerchips.h create mode 100644 src/drawing/playerdeal.c create mode 100644 src/drawing/playerdeal.h create mode 100644 src/sprites/spritecardsmall.c create mode 100644 src/sprites/spritecardsmall.h diff --git a/assets/images/card_back_small.png b/assets/images/card_back_small.png new file mode 100644 index 0000000000000000000000000000000000000000..024ebe44128056ee4a54e5eb68b2a2a2141f48fd GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^96&6SntU5<*QjxBVtPD9lqBV&BXvJ=b|tGG5|3E6N6o9obdYUQkn?} zH+F-#T^d8zot@)8S7*3vZG@soDACy;`I>UnHZGNrr8h4L$^e3-!QPaog{%3o@vW}h zy{q5=@kG{OwUbPBRy=~TXs|yIwubClgr6&JxD7kQ5GUakL$tEjFS>dH3e$mMVJ)lSz&HQ|Ocv}tn=6IA zZltnl3}16u9n;6OO68OoqDx&0G4;8f@{+i;xe7lZfC8F2+W{aHV1N+;64(>VX1NE75Chb3_zRwTD7aS RR|0{7`pPiQdK5=PP)4~RvuOYT literal 0 HcmV?d00001 diff --git a/src/conversation/items/gameintro.c b/src/conversation/items/gameintro.c index b1d4b7d..c2cf644 100644 --- a/src/conversation/items/gameintro.c +++ b/src/conversation/items/gameintro.c @@ -10,6 +10,7 @@ void conversationQueueGameBegin() { char buffer[TEXTBOX_BUFFER_MAX]; - sprintf(STR_GAME_BEGIN, POKER_GAME_BLINDS_CURRENT * 2, POKER_GAME_BLINDS_CURRENT); + sprintf(buffer, STR_GAME_BEGIN, POKER_GAME_BLINDS_CURRENT * 2, POKER_GAME_BLINDS_CURRENT); conversationTextboxSetText(buffer); + QUEUE_ITEM = QUEUE_DEAL_CARDS; } \ No newline at end of file diff --git a/src/conversation/queue.c b/src/conversation/queue.c index 751e887..10b83d5 100644 --- a/src/conversation/queue.c +++ b/src/conversation/queue.c @@ -23,7 +23,7 @@ void conversationQueueDebug() { void conversationQueueDealCards() { QUEUE_ITEM = QUEUE_BEGIN_BETTING; - conversationTextboxSetText(STR_POKER_GAME_CARDS_DEALT); + conversationQueueNext(); } void conversationQueueStart() { diff --git a/src/drawing/playerchips.c b/src/drawing/playerchips.c new file mode 100644 index 0000000..8c686c4 --- /dev/null +++ b/src/drawing/playerchips.c @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "playerchips.h" + +// POKER_HUMAN_INDEX +inline void playerChipsDraw() { + char stringBuffer[24]; + char tileBuffer[24];// TODO convert magics into a definition + uint8_t i; + + sprintf(stringBuffer, STR_CHIPS_DISPLAY, POKER_PLAYERS[POKER_HUMAN_INDEX].chips); + i = spriteFontBufferStringToTiles(stringBuffer, tileBuffer); + spriteBufferBackground(0x00, 0x0C, i, 0x01, tileBuffer); +} \ No newline at end of file diff --git a/src/drawing/playerchips.h b/src/drawing/playerchips.h new file mode 100644 index 0000000..a7a67fc --- /dev/null +++ b/src/drawing/playerchips.h @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "../libs.h" +#include "../sprites/spritefont.h" +#include "../poker/poker.h" +#include "../strings.h" +#include "../sprites/sprites.h" + +inline void playerChipsDraw(); \ No newline at end of file diff --git a/src/drawing/playerdeal.c b/src/drawing/playerdeal.c new file mode 100644 index 0000000..6a42c3e --- /dev/null +++ b/src/drawing/playerdeal.c @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "playerdeal.h" + +const uint8_t DEAL_CARD_X = 0x00; +const uint8_t DEAL_CARD_Y = 0x00; + +void playerDealCardRender() { + +} \ No newline at end of file diff --git a/src/drawing/playerdeal.h b/src/drawing/playerdeal.h new file mode 100644 index 0000000..f347fe1 --- /dev/null +++ b/src/drawing/playerdeal.h @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "../libs.h" +#include "../poker/poker.h" + +#define PLAYER_DEAL_SPRITE_0 0x00 +#define PLAYER_DEAL_SPRITE_1 PLAYER_DEAL_SPRITE_0 + 0x01 + +extern const uint8_t DEAL_CARD_X; +extern const uint8_t DEAL_CARD_Y; \ No newline at end of file diff --git a/src/interrupts.c b/src/interrupts.c index b23626f..c92709f 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -10,6 +10,7 @@ void interruptOnScanline() { if(LYC_REG == 0) { LCDC_REG |= LCDCF_BG8000; + if((TEXTBOX_STATE & TEXTBOX_STATE_VISIBLE) != 0) { LYC_REG = INTERRUPT_TEXTBOX_VRAM; } diff --git a/src/main.c b/src/main.c index 9716cd7..160e236 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,9 @@ */ #include "main.h" - +#include "drawing/playerchips.h" +#include "sprites/sprites.h" +#include "sprites/spritecardsmall.h" void main() { int16_t j; @@ -18,14 +20,7 @@ void main() { // Create a critical section for some video stuff CRITICAL { DISPLAY_OFF; - LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_BG8000 | LCDCF_BG9800 | LCDCF_BGON; - /* - * LCD = Off - * WindowBank = 0x9C00 - * BG Chr = 0x8800 - * BG Bank = 0x9800 - * BG = On - */ + LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_BG8000 | LCDCF_BG9800 | LCDCF_BGON | LCDCF_OBJ16 | LCDCF_OBJON; STAT_REG |= STATF_LYC; LYC_REG = 0x00; @@ -48,6 +43,7 @@ void main() { spriteCardsBuffer(); spriteFontBuffer(); spriteBorderBuffer(); + spriteCardSmallBuffer(); conversationTextboxInit(); conversationQueueInit(); @@ -59,11 +55,6 @@ void main() { } spriteBufferBackground(0x00, 0x00, GB_BACKGROUND_COLUMNS, GB_BACKGROUND_ROWS, filled); - // Card Test - uint8_t cardTiles[SPRITE_CARD_TILE_COUNT]; - spriteCardBufferTiles(cardTiles, CARD_SPADES_QUEEN); - spriteBufferBackground(0x00, 0x00, SPRITE_CARD_WIDTH, SPRITE_CARD_HEIGHT, cardTiles); - // Now turn the screen on DISPLAY_ON; enable_interrupts(); @@ -72,11 +63,21 @@ void main() { // Begin game conversationQueueNext(); + spriteBufferSprite(0x00, SPRITE_CARD_SMALL); + spriteBufferSprite(0x01, SPRITE_CARD_SMALL); + set_sprite_prop(0x01, S_FLIPX); + // Begin the loop while(1) { // Perform non-graphical code updates wait_vbl_done(); + uint8_t posX, posY; + posX = 16; + posY = 16; + move_sprite(0x00, posX, posY); + move_sprite(0x01, posX + 0x08, posY); + // Update the input state INPUT_LAST = INPUT_STATE; INPUT_STATE = joypad(); @@ -94,7 +95,6 @@ void main() { // Update conversation fade effect conversationFadeUpdate(); - // mainDebugDraw(); - LCDC_REG |= LCDCF_BG8000; + playerChipsDraw(); } } \ No newline at end of file diff --git a/src/sprites/cards/spritecardscommon.h b/src/sprites/cards/spritecardscommon.h index 8bb9f3d..280d299 100644 --- a/src/sprites/cards/spritecardscommon.h +++ b/src/sprites/cards/spritecardscommon.h @@ -13,6 +13,7 @@ #include "../sprites.h" #define SPRITE_CARD_VRAM_START SPRITE_TILESET_VRAM_END_LOW +#define SPRITE_CARD_VRAM_END SPRITE_CARD_VRAM_START + CARDS_TILES_IMAGE_TILES #define SPRITE_CARD_BLANK SPRITE_TILESET_WHITE_LOW // Information about the card as a tilemap diff --git a/src/sprites/spritecardsmall.c b/src/sprites/spritecardsmall.c new file mode 100644 index 0000000..06de590 --- /dev/null +++ b/src/sprites/spritecardsmall.c @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "spritecardsmall.h" + +inline void spriteCardSmallBuffer() { + spriteBufferLow(SPRITE_CARD_SMALL_VRAM_START, CARD_BACK_SMALL_IMAGE_TILES, CARD_BACK_SMALL_IMAGE); +} + diff --git a/src/sprites/spritecardsmall.h b/src/sprites/spritecardsmall.h new file mode 100644 index 0000000..68424b5 --- /dev/null +++ b/src/sprites/spritecardsmall.h @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2022 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "../libs.h" +#include "sprites.h" +#include "CARD_BACK_SMALL.h" +#include "spritecards.h" + +#define SPRITE_CARD_SMALL_VRAM_START SPRITE_CARD_VRAM_END +#define SPRITE_CARD_SMALL_VRAM_END SPRITE_CARD_SMALL_VRAM_START + CARD_BACK_SMALL_IMAGE_TILES + +#define SPRITE_CARD_SMALL SPRITE_CARD_SMALL_VRAM_START + +inline void spriteCardSmallBuffer(); \ No newline at end of file diff --git a/src/sprites/spritefont.c b/src/sprites/spritefont.c index f7d635e..cccefc5 100644 --- a/src/sprites/spritefont.c +++ b/src/sprites/spritefont.c @@ -13,4 +13,16 @@ inline void spriteFontBuffer() { inline uint8_t spriteFontTileFromChar(char character) { return character - SPRITE_FONT_FIRST_CHARACTER + SPRITE_FONT_VRAM_START; +} + +inline uint8_t spriteFontBufferStringToTiles(char *string, char *tiles) { + char c; + uint8_t i; + + i = 0; + while((c = string[i]) != '\0') { + tiles[i++] = spriteFontTileFromChar(c); + } + + return i; } \ No newline at end of file diff --git a/src/sprites/spritefont.h b/src/sprites/spritefont.h index cd44161..2aa930b 100644 --- a/src/sprites/spritefont.h +++ b/src/sprites/spritefont.h @@ -28,4 +28,14 @@ inline void spriteFontBuffer(); * @param character Character to get the tile index from. * @return The tile index for the given character. */ -inline uint8_t spriteFontTileFromChar(char character); \ No newline at end of file +inline uint8_t spriteFontTileFromChar(char character); + +/** + * Buffers a character array into a tile array, does not care about length nor + * newlines, you will need to handle this yourself. + * + * @param string String to buffer. + * @param tiles Tile array to buffer in to. + * @return The length of the string. + */ +inline uint8_t spriteFontBufferStringToTiles(char *string, char *tiles); \ No newline at end of file diff --git a/src/sprites/sprites.c b/src/sprites/sprites.c index ef78e38..9eb362a 100644 --- a/src/sprites/sprites.c +++ b/src/sprites/sprites.c @@ -43,4 +43,8 @@ inline void spriteBufferWindow( SPRITE_VRAM_TILEMAP_WINDOW_LOW, tiles ); +} + +inline void spriteBufferSprite(uint8_t spriteIndex, uint8_t tile) { + set_sprite_tile(spriteIndex, tile); } \ No newline at end of file diff --git a/src/sprites/sprites.h b/src/sprites/sprites.h index 0067e47..87669b2 100644 --- a/src/sprites/sprites.h +++ b/src/sprites/sprites.h @@ -43,4 +43,6 @@ inline void spriteBufferWindow( uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t *tiles -); \ No newline at end of file +); + +inline void spriteBufferSprite(uint8_t spriteIndex, uint8_t tile); \ No newline at end of file diff --git a/src/strings.c b/src/strings.c index 03619be..deee5a3 100644 --- a/src/strings.c +++ b/src/strings.c @@ -7,16 +7,11 @@ #include "strings.h" -const char STR_GAME_BEGIN[] = "The blinds are set %u for the big, and %u for the small blinds."; - - - - - - - - const char STR_ERROR[] = "An error\nhas occured"; +const char STR_GAME_BEGIN[] = "The blinds are set %u for the big, and %u for the small blinds."; +const char STR_CHIPS_DISPLAY[] = "Chips $%u"; + + const char STR_HELLO[] = "Hello World, How are you today?\nGood thanks. Thank god!"; const char STR_POKER_GAME_START[] = "Poker game started"; diff --git a/src/strings.h b/src/strings.h index 7cd2ccd..da957aa 100644 --- a/src/strings.h +++ b/src/strings.h @@ -8,14 +8,11 @@ #pragma once #include "libs.h" -extern const char STR_GAME_BEGIN[]; - - - - - - extern const char STR_ERROR[]; +extern const char STR_GAME_BEGIN[]; +extern const char STR_CHIPS_DISPLAY[]; + + extern const char STR_HELLO[]; extern const char STR_POKER_GAME_START[];