Adding new textbox stuff
This commit is contained in:
@@ -7,7 +7,10 @@
|
||||
|
||||
#include "textbox.h"
|
||||
|
||||
char *TEXTBOX_TEXT;
|
||||
char TEXTBOX_TEXT[TEXTBOX_BUFFER_MAX];
|
||||
uint8_t TEXTBOX_ROW_COUNT;
|
||||
uint8_t TEXTBOX_ROW_CURRENT;
|
||||
|
||||
uint8_t TEXTBOX_TEXT_LENGTH;
|
||||
uint8_t TEXTBOX_STATE;
|
||||
uint8_t TEXTBOX_SCROLL;
|
||||
@@ -18,7 +21,7 @@ inline void conversationTextboxInit() {
|
||||
uint8_t TEXTBOX_TILES[TEXTBOX_TILES_MAX];
|
||||
|
||||
// Reset textbox state
|
||||
TEXTBOX_TEXT = NULL;
|
||||
TEXTBOX_TEXT[0] = '\0';
|
||||
TEXTBOX_STATE = 0;
|
||||
TEXTBOX_TEXT_LENGTH = 0;
|
||||
TEXTBOX_SCROLL = 0;
|
||||
@@ -54,11 +57,19 @@ inline void conversationTextboxInit() {
|
||||
|
||||
void conversationTextboxSetText(char *text, uint8_t length) {
|
||||
uint8_t i, j;
|
||||
char c;
|
||||
uint8_t TEXTBOX_TILES[TEXTBOX_CHAR_ROWS * TEXTBOX_CHARS_PER_ROW];
|
||||
|
||||
TEXTBOX_TEXT_LENGTH = 0;
|
||||
i = 0;
|
||||
|
||||
while((c = text[i]) != '\0') {
|
||||
TEXTBOX_TEXT[i] = c;
|
||||
TEXTBOX_TEXT_LENGTH++;
|
||||
i++;
|
||||
}
|
||||
|
||||
// Reset textbox state
|
||||
TEXTBOX_TEXT = text;
|
||||
TEXTBOX_TEXT_LENGTH = length;
|
||||
TEXTBOX_STATE = TEXTBOX_STATE_VISIBLE;
|
||||
TEXTBOX_SCROLL = 0;
|
||||
TEXTBOX_CHAR_POSITION = 0;
|
||||
|
@@ -32,6 +32,8 @@
|
||||
|
||||
#define TEXTBOX_CHARS_PER_ROW (TEXTBOX_WIDTH_IN_TILES - 2)
|
||||
#define TEXTBOX_CHAR_ROWS (TEXTBOX_HEIGHT_IN_TILES - 2)
|
||||
#define TEXTBOX_CHARS_MAX (TEXTBOX_CHAR_ROWS * TEXTBOX_CHARS_PER_ROW)
|
||||
#define TEXTBOX_BUFFER_MAX (TEXTBOX_CHARS_MAX * 3)
|
||||
|
||||
#define TEXTBOX_TILES_PER_ROW TEXTBOX_WIDTH_IN_TILES
|
||||
#define TEXTBOX_TILES_ROWS 3
|
||||
@@ -41,7 +43,10 @@
|
||||
STR_ ## name ## _DATA, STR_ ## name ## _LENGTH\
|
||||
)
|
||||
|
||||
extern char *TEXTBOX_TEXT;
|
||||
extern char TEXTBOX_TEXT[TEXTBOX_BUFFER_MAX];
|
||||
extern uint8_t TEXTBOX_ROW_COUNT;
|
||||
extern uint8_t TEXTBOX_ROW_CURRENT;
|
||||
|
||||
extern uint8_t TEXTBOX_TEXT_LENGTH;
|
||||
extern uint8_t TEXTBOX_STATE;
|
||||
extern uint8_t TEXTBOX_SCROLL;
|
||||
|
@@ -12,3 +12,4 @@
|
||||
// #include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <rand.h>
|
||||
#include <string.h>
|
112
src/main.c
112
src/main.c
@@ -7,11 +7,11 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
uint8_t mainGetChar(char c) {
|
||||
inline uint8_t mainGetChar(char c) {
|
||||
return c - 33 + 4;
|
||||
}
|
||||
|
||||
void mainBufferChar(uint8_t card, uint8_t *tiles) {
|
||||
inline void mainBufferChar(uint8_t card, uint8_t *tiles) {
|
||||
uint8_t suit, number;
|
||||
|
||||
if(card >= CARD_DECK_SIZE) {
|
||||
@@ -81,56 +81,8 @@ void mainBufferChar(uint8_t card, uint8_t *tiles) {
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
int16_t j;
|
||||
uint8_t filled[GB_BACKGROUND_COLUMNS*GB_BACKGROUND_ROWS];
|
||||
|
||||
// Set up the GAMEBOY's registers.
|
||||
disable_interrupts();
|
||||
DISPLAY_OFF;
|
||||
LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_BGON;
|
||||
BGP_REG = 0xE4U;
|
||||
|
||||
// Init the random seed
|
||||
initarand(DIV_REG);
|
||||
|
||||
// Prepare time and input
|
||||
INPUT_STATE = joypad();
|
||||
|
||||
// Init things
|
||||
timeInit();
|
||||
commonTilesInit();
|
||||
conversationTextboxInit();
|
||||
conversationQueueInit();
|
||||
pokerInit();
|
||||
|
||||
// Fill screen white
|
||||
for(j = 0; j < 0x20*0x20; j++) filled[j] = COMMON_TILE_3;
|
||||
set_bkg_tiles(0x00, 0x00, GB_BACKGROUND_COLUMNS, GB_BACKGROUND_ROWS, filled);
|
||||
SCX_REG = 0x00;
|
||||
SCY_REG = 0x00;
|
||||
|
||||
// Now turn the screen on
|
||||
DISPLAY_ON;
|
||||
enable_interrupts();
|
||||
wait_vbl_done();
|
||||
|
||||
// Alright begin the game logic here.
|
||||
conversationQueueNext();
|
||||
|
||||
// Begin the loop
|
||||
while(1) {
|
||||
// Wait for VSYNC
|
||||
wait_vbl_done();
|
||||
|
||||
// Update the input state
|
||||
INPUT_STATE = joypad();
|
||||
|
||||
conversationTextboxUpdate();
|
||||
conversationPauseUpdate();
|
||||
conversationFadeUpdate();
|
||||
|
||||
|
||||
inline void mainDebugDraw() {
|
||||
uint8_t j;
|
||||
|
||||
// DEBUG DRAW
|
||||
uint8_t tiles[10];
|
||||
@@ -176,6 +128,62 @@ void main() {
|
||||
}
|
||||
|
||||
set_bkg_tiles(0x00, POKER_PLAYER_COUNT + 1, 10, 1, tiles);
|
||||
}
|
||||
|
||||
void main() {
|
||||
int16_t j;
|
||||
uint8_t filled[GB_BACKGROUND_COLUMNS*GB_BACKGROUND_ROWS];
|
||||
|
||||
// Set up the GAMEBOY's registers.
|
||||
disable_interrupts();
|
||||
DISPLAY_OFF;
|
||||
LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_BGON;
|
||||
BGP_REG = 0xE4U;
|
||||
|
||||
// Init the random seed
|
||||
initarand(DIV_REG);
|
||||
|
||||
// Prepare time and input
|
||||
INPUT_STATE = joypad();
|
||||
|
||||
// Init things
|
||||
timeInit();
|
||||
commonTilesInit();
|
||||
conversationTextboxInit();
|
||||
// conversationQueueInit();
|
||||
// pokerInit();
|
||||
|
||||
// Fill screen white
|
||||
for(j = 0; j < 0x20*0x20; j++) filled[j] = COMMON_TILE_3;
|
||||
set_bkg_tiles(0x00, 0x00, GB_BACKGROUND_COLUMNS, GB_BACKGROUND_ROWS, filled);
|
||||
SCX_REG = 0x00;
|
||||
SCY_REG = 0x00;
|
||||
|
||||
// Now turn the screen on
|
||||
DISPLAY_ON;
|
||||
enable_interrupts();
|
||||
wait_vbl_done();
|
||||
|
||||
// Alright begin the game logic here.
|
||||
// conversationQueueNext();
|
||||
char DEBUG_TEXT[] = "HEY";
|
||||
uint8_t DEBUG_TEXT_LENGTH = 3;
|
||||
for(j = 0; j < DEBUG_TEXT_LENGTH; j++) DEBUG_TEXT[j] = DEBUG_TEXT[j] - 33 + 4;
|
||||
conversationTextboxSetText(DEBUG_TEXT, DEBUG_TEXT_LENGTH);
|
||||
|
||||
// Begin the loop
|
||||
while(1) {
|
||||
// Wait for VSYNC
|
||||
wait_vbl_done();
|
||||
|
||||
// Update the input state
|
||||
INPUT_STATE = joypad();
|
||||
|
||||
conversationTextboxUpdate();
|
||||
// conversationPauseUpdate();
|
||||
// conversationFadeUpdate();
|
||||
|
||||
// mainDebugDraw():
|
||||
|
||||
// Tick time.
|
||||
timeUpdate();
|
||||
|
@@ -39,7 +39,7 @@ void pokerInit() {
|
||||
// TODO: Should this be randomized?
|
||||
POKER_PLAYER_DEALER = 0;
|
||||
POKER_GAME_BLINDS_CURRENT = 10;
|
||||
POKER_PLAYER_COUNT = 3;
|
||||
POKER_PLAYER_COUNT = POKER_PLAYER_COUNT_MAX;
|
||||
|
||||
// Set up players
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
@@ -145,6 +145,7 @@ inline void pokerBet(uint8_t player, uint16_t amount) {
|
||||
// player 2 has $700, and bets all o it. A new $300 sidepot auto creates
|
||||
// player 3 has $500 and bets all of it, Another sidepot with $200 is auto made.
|
||||
if(POKER_POT_CURRENT == POKER_POT_COUNT) POKER_POT_COUNT++;
|
||||
|
||||
POKER_PLAYERS[player].chips -= amount;
|
||||
POKER_POTS[POKER_POT_CURRENT].chips += amount;
|
||||
POKER_POTS[POKER_POT_CURRENT].players[player] += amount;
|
||||
|
Reference in New Issue
Block a user