Browse Source

help page added

pull/1/head
Alexander Kramer 2 years ago
parent
commit
622bd52791
Signed by: alex
GPG Key ID: E51332D1715AACFD
  1. 76
      inc/init.asm
  2. 20
      inc/input.asm
  3. 8
      maps/background.asm
  4. 4
      maps/window-game.asm
  5. 6
      maps/window-help.asm
  6. 17
      tiles/sign-slash.asm
  7. 107
      wordle.asm
  8. BIN
      wordle.gb

76
inc/init.asm

@ -22,13 +22,72 @@ init_state_menu:
; Initialise everything for help screen
init_state_help:
ld a, STATE_HELP
ld [current_state], a
; turn the screen off
ld a, DISPLAY_OFF
ld [LCD_CONTROL_REGISTER], a
call clear_message
; set the background position
ld a, 0
ld [BKG_POS_X_REGISTER], a
ld a, $9a
ld [BKG_POS_Y_REGISTER], a
; set the window position
ld a, 3
ld [WND_POS_X_REGISTER], a
ld a, $70
ld [WND_POS_Y_REGISTER], a
ld hl, window_help
call load_window_map
; set a fixed game state
ld hl, current_word
ld de, help_word
ld c, 65
.set_gamestate:
ld a, [de]
ld [hl], a
inc de
inc hl
dec c
jp nz, .set_gamestate
; This is only possible because the memory space of these
; two variables is located directly after each other.
call update_hint_markings
call update_guess_objects
; turn the screen on
ld a, DISPLAY_ON + TLS_USE_LOC_8000 \
+ BKG_DISPLAY_ON + BKG_USE_LOC_9800 \
+ WND_DISPLAY_ON + WND_USE_LOC_9C00 \
+ OBJ_DISPLAY_ON + OBJ_SIZE_8X8
ld [LCD_CONTROL_REGISTER], a
ret
; Initialise everything for the main game state
init_state_game:
; set the current state
ld a, STATE_GAME
ld [current_state], a
; turn the screen off
ld a, DISPLAY_OFF
ld [LCD_CONTROL_REGISTER], a
call select_word
call clear_message
; set the background position
ld a, 0
@ -39,11 +98,12 @@ init_state_game:
; set the window position
ld a, 3
ld [WND_POS_X_REGISTER], a
ld a, $5e
ld a, $70
ld [WND_POS_Y_REGISTER], a
; clear messages
call clear_message
; load the window data
ld hl, window_game
call load_window_map
; initialise some more variables
ld a, 0
@ -151,17 +211,17 @@ load_background_map:
; Load the window map into the vram
; -> hl
load_window_map:
ld bc, window
ld hl, WND_LOC_9C00
ld bc, WND_LOC_9C00
ld d, 32
ld e, 4
.loop:
ld a, [bc]
ld [hl], a
inc bc
ld a, [hl]
ld [bc], a
inc hl
inc bc
dec d
jp nz, .loop

20
inc/input.asm

@ -49,9 +49,10 @@ handle_input_menu:
and a, INPUT_UP | INPUT_DOWN
jp z, .check_confirm
ld a, [sub_state]
xor a, %00000001 ; flip the last bit
; flip the corresponding bits
xor a, STATE_MENU_START + STATE_MENU_HELP
ld [sub_state], a
and a, %00000001
and a, STATE_MENU_START
jp z, .switch_to_help
.switch_to_start
call show_message_menu_start
@ -64,7 +65,6 @@ handle_input_menu:
ld a, c
and a, INPUT_START | INPUT_A
jp z, .return
ld a, [sub_state]
and a, STATE_MENU_START
jp z, .help_selected
@ -72,12 +72,23 @@ handle_input_menu:
call init_state_game
jp .return
.help_selected
call init_state_help
jp .return
.return
ret
handle_input_help:
ld a, c
and a, INPUT_START
jp z, .return
call init_state_game
.return
ret
; React on input within the main game
; <- c: changed keys since last read
handle_input_game:
@ -264,7 +275,7 @@ update_cursor_objects:
ld a, [selected_letter_y]
ld b, $08
call multiply_ab
add a, $86
add a, $80
ld [hl+], a
; horizontal position
@ -294,3 +305,4 @@ update_cursor_objects:
ld a, OBJ_ATTR_PALETTE1
ld [hl+], a
ret

8
maps/background.asm

@ -2,10 +2,10 @@
DB $1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$22,$23,$24,$25,$26,$27,$28,$29,$2a,$2b,$2c,$2d,$2e,$2f,$30,$31,$32,$33,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$34,$35,$36,$37,$38,$39,$3a,$3b,$3c,$3d,$3e,$3f,$40,$41,$42,$43,$44,$45,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$46,$47,$48,$49,$4a,$4b,$4c,$4d,$4e,$4f,$50,$51,$52,$53,$54,$55,$56,$57,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$58,$59,$5a,$5b,$5c,$5d,$5e,$5f,$60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$23,$24,$25,$26,$27,$28,$29,$2a,$2b,$2c,$2d,$2e,$2f,$30,$31,$32,$33,$34,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$35,$36,$37,$38,$39,$3a,$3b,$3c,$3d,$3e,$3f,$40,$41,$42,$43,$44,$45,$46,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$47,$48,$49,$4a,$4b,$4c,$4d,$4e,$4f,$50,$51,$52,$53,$54,$55,$56,$57,$58,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c
DB $1c,$59,$5a,$5b,$5c,$5d,$5e,$5f,$60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$1c,$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$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b

6
maps/window-help.asm

@ -0,0 +1,6 @@
; Window map while within help
DB $1b,$1b,$13,$14,$01,$12,$14,$1b,$1b,$0e,$05,$17,$1b,$07,$01,$0d,$05,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b
DB $1b,$1b,$13,$05,$0c,$05,$03,$14,$1b,$03,$08,$05,$03,$0b,$1b,$17,$0f,$12,$04,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b
DB $1b,$1b,$01,$22,$02,$1b,$1b,$1b,$1b,$04,$05,$22,$13,$05,$0c,$05,$03,$14,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b
DB $1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b,$1b

17
tiles/sign-slash.asm

@ -0,0 +1,17 @@
; Slash
DB %00000000, \
%00000000, \
%00000010, \
%00000010, \
%00000100, \
%00000100, \
%00001000, \
%00001000, \
%00010000, \
%00010000, \
%00100000, \
%00100000, \
%01000000, \
%01000000, \
%10000000, \
%10000000, \

107
wordle.asm

@ -3,11 +3,12 @@ include "inc/constants.asm"
;; Game specific constants
; Game states
STATE_MENU EQU %00000001
STATE_MENU_START EQU %01000001
STATE_MENU_HELP EQU %10000001
STATE_GAME EQU %00000010
STATE_LOST EQU %00000100
STATE_WON EQU %00001100
STATE_MENU_START EQU %01000000
STATE_MENU_HELP EQU %10000000
STATE_HELP EQU %00000010
STATE_GAME EQU %00000100
STATE_LOST EQU %00001000
STATE_WON EQU %00011000
; Marker for invalid or undefined values
NULL EQU $00
@ -21,6 +22,7 @@ TILE_ENTER EQU $1e
TILE_RIGHT EQU $1f
TILE_MISPLACED EQU $20
TILE_WRONG EQU $21
TILE_SLASH EQU $22
@ -63,7 +65,6 @@ main:
; load the video data
call init_palettes
call load_tiles
call load_window_map
call load_background_map
; initialise the objects
@ -103,10 +104,18 @@ main_loop:
.in_menu:
cp a, STATE_MENU
jp nz, .in_game
jp nz, .in_help
call handle_input_menu
jp .cleanup
.in_help:
cp a, STATE_HELP
jp nz, .in_game
call handle_input_help
call update_hint_markings
call update_guess_objects
jp .cleanup
.in_game:
cp a, STATE_GAME
jp nz, .in_won
@ -176,6 +185,8 @@ tile_misplaced:
include "tiles/sign-misplaced.asm"
tiles_wrong:
include "tiles/sign-wrong.asm"
tiles_slash:
include "tiles/sign-slash.asm"
tiles_logo:
include "tiles/logo.asm"
tiles_end:
@ -186,8 +197,10 @@ tiles_end:
maps_start:
background:
include "maps/background.asm"
window:
include "maps/window.asm"
window_help:
include "maps/window-help.asm"
window_game:
include "maps/window-game.asm"
maps_end:
dictionary:
@ -196,6 +209,26 @@ dictionary_end:
DB
; Help data
help_word:
DB $12, $09, $07, $08, $14 ; right
help_guess:
DB $06, $01, $15, $0c, $14 ; fault
DB $07, $09, $12, $14, $08 ; girth
DB $12, $09, $07, $08, $14 ; right
DB $0f, $0e, $0c, $19, $00 ; only
DB $13, $09, $18, $00, $00 ; six
DB $14, $12, $09, $05, $13 ; tries
help_guess_hints:
DB TILE_WRONG, TILE_WRONG, TILE_WRONG, TILE_WRONG, TILE_RIGHT
DB TILE_MISPLACED, TILE_MISPLACED, TILE_MISPLACED, TILE_MISPLACED, TILE_MISPLACED
DB TILE_RIGHT, TILE_RIGHT, TILE_RIGHT, TILE_RIGHT, TILE_RIGHT
DB TILE_WHITE, TILE_WHITE, TILE_WHITE, TILE_WHITE, TILE_WHITE
DB TILE_WHITE, TILE_WHITE, TILE_WHITE, TILE_WHITE, TILE_WHITE
DB TILE_WHITE, TILE_WHITE, TILE_WHITE, TILE_WHITE, TILE_WHITE
; Messages
message_clear:
@ -217,8 +250,8 @@ message_menu_start:
DB $88, $50, 20, OBJ_ATTR_PALETTE1 ; T
DB $88, $60, 07, OBJ_ATTR_PALETTE1 ; G
DB $88, $68, 01, OBJ_ATTR_PALETTE1 ; A
DB $88, $70, 13, OBJ_ATTR_PALETTE1 ; G
DB $88, $78, 05, OBJ_ATTR_PALETTE1 ; A
DB $88, $70, 13, OBJ_ATTR_PALETTE1 ; M
DB $88, $78, 05, OBJ_ATTR_PALETTE1 ; E
message_menu_help:
DB $90, $30, 08, OBJ_ATTR_PALETTE1 ; H
@ -232,36 +265,36 @@ message_menu_help:
DB $90, $80, 25, OBJ_ATTR_PALETTE1 ; Y
message_unknown:
DB $7a, $38, 21, OBJ_ATTR_PALETTE1 ; U
DB $7a, $40, 14, OBJ_ATTR_PALETTE1 ; N
DB $7a, $48, 11, OBJ_ATTR_PALETTE1 ; k
DB $7a, $50, 14, OBJ_ATTR_PALETTE1 ; N
DB $7a, $58, 15, OBJ_ATTR_PALETTE1 ; O
DB $7a, $60, 23, OBJ_ATTR_PALETTE1 ; W
DB $7a, $68, 14, OBJ_ATTR_PALETTE1 ; N
DB $74, $38, 21, OBJ_ATTR_PALETTE1 ; U
DB $74, $40, 14, OBJ_ATTR_PALETTE1 ; N
DB $74, $48, 11, OBJ_ATTR_PALETTE1 ; k
DB $74, $50, 14, OBJ_ATTR_PALETTE1 ; N
DB $74, $58, 15, OBJ_ATTR_PALETTE1 ; O
DB $74, $60, 23, OBJ_ATTR_PALETTE1 ; W
DB $74, $68, 14, OBJ_ATTR_PALETTE1 ; N
DB $00, $00, 0, 0
DB $00, $00, 0, 0
message_won:
DB $7a, $38, 25, OBJ_ATTR_PALETTE1 ; Y
DB $7a, $40, 15, OBJ_ATTR_PALETTE1 ; O
DB $7a, $48, 21, OBJ_ATTR_PALETTE1 ; U
DB $7a, $58, 23, OBJ_ATTR_PALETTE1 ; W
DB $7a, $60, 15, OBJ_ATTR_PALETTE1 ; O
DB $7a, $68, 14, OBJ_ATTR_PALETTE1 ; N
DB $74, $38, 25, OBJ_ATTR_PALETTE1 ; Y
DB $74, $40, 15, OBJ_ATTR_PALETTE1 ; O
DB $74, $48, 21, OBJ_ATTR_PALETTE1 ; U
DB $74, $58, 23, OBJ_ATTR_PALETTE1 ; W
DB $74, $60, 15, OBJ_ATTR_PALETTE1 ; O
DB $74, $68, 14, OBJ_ATTR_PALETTE1 ; N
DB $00, $00, 0, 0
DB $00, $00, 0, 0
DB $00, $00, 0, 0
message_lost:
DB $7a, $30, 9, OBJ_ATTR_PALETTE1 ; I
DB $7a, $38, 20, OBJ_ATTR_PALETTE1 ; T
DB $7a, $40, 19, OBJ_ATTR_PALETTE1 ; S
DB $7a, $50, 0, OBJ_ATTR_PALETTE1 ; guess[0]
DB $7a, $58, 0, OBJ_ATTR_PALETTE1 ; guess[1]
DB $7a, $60, 0, OBJ_ATTR_PALETTE1 ; guess[2]
DB $7a, $68, 0, OBJ_ATTR_PALETTE1 ; guess[3]
DB $7a, $70, 0, OBJ_ATTR_PALETTE1 ; guess[4]
DB $74, $30, 9, OBJ_ATTR_PALETTE1 ; I
DB $74, $38, 20, OBJ_ATTR_PALETTE1 ; T
DB $74, $40, 19, OBJ_ATTR_PALETTE1 ; S
DB $74, $50, 0, OBJ_ATTR_PALETTE1 ; guess[0]
DB $74, $58, 0, OBJ_ATTR_PALETTE1 ; guess[1]
DB $74, $60, 0, OBJ_ATTR_PALETTE1 ; guess[2]
DB $74, $68, 0, OBJ_ATTR_PALETTE1 ; guess[3]
DB $74, $70, 0, OBJ_ATTR_PALETTE1 ; guess[4]
DB $00, $00, 0, 0
@ -276,7 +309,7 @@ obj_selected_letter:
obj_guess_letters:
DS 120
obj_message_letters:
DS 32
DS 36
obj_end:
obj_dma_padding:
DS 160 - (obj_end - obj_start)
@ -302,10 +335,6 @@ current_state:
sub_state:
DB
; Saves the current word
current_word:
DS 5
; Number of the current guess
current_guess:
DB
@ -314,6 +343,10 @@ current_guess:
current_char:
DB
; Saves the current word
current_word:
DS 5
; The guess attempts
guesses:
DS 30

BIN
wordle.gb

Binary file not shown.
Loading…
Cancel
Save