Files
giochino-amiga/game_logic.s
2025-12-01 18:23:49 +01:00

190 lines
3.7 KiB
ArmAsm

; Game Logic Module
; ---------------------------------------------------------------------------
INCDIR "c:/Users/capitano/Documents/giochino/"
INCLUDE "custom.i"
; XDEF InitGameLogic
; XDEF UpdateGame
; XDEF GameState
; XDEF Stress
; XDEF Satisfaction
; XDEF GameTime
; XDEF EmailCount
; XREF ReadInput
; XREF LastKey
; XREF DrawText
; XREF ClearScreen
; XREF EmailList
; SECTION Code,CODE_C
; Constants
STATE_TITLE EQU 0
STATE_PLAYING EQU 1
STATE_GAMEOVER EQU 2
START_TIME EQU 9*60 ; 9:00 AM in minutes
END_TIME EQU 17*60 ; 5:00 PM in minutes
MAX_STRESS EQU 100
START_SATIS EQU 50
InitGameLogic:
move.b #STATE_TITLE,GameState
rts
StartGame:
move.b #STATE_PLAYING,GameState
move.b #0,Stress
move.b #START_SATIS,Satisfaction
move.w #START_TIME,GameTime
move.w #0,EmailCount
bsr ClearScreen
bsr SpawnEmail
rts
SpawnEmail:
; For now, just pick the first email always, or cycle
; TODO: Randomize
lea EmailList,a0
move.l a0,CurrentEmail
bsr DrawEmail
rts
DrawEmail:
move.l CurrentEmail,a0
cmp.l #0,a0
beq .done
; Draw Sender (at 2, 12)
move.l 2(a0),a0 ; Get Sender Ptr
moveq #2,d0 ; X
moveq #12,d1 ; Y
bsr DrawText
; Draw Subject (at 2, 14)
move.l CurrentEmail,a0
move.l 6(a0),a0 ; Get Subject Ptr
moveq #2,d0
moveq #14,d1
bsr DrawText
; Draw Body (at 2, 16)
move.l CurrentEmail,a0
move.l 10(a0),a0 ; Get Body Ptr
moveq #2,d0
moveq #16,d1
bsr DrawText
; Draw Options (at 2, 20 and 2, 22)
move.l CurrentEmail,a0
move.l 14(a0),a0 ; Opt1
moveq #2,d0
moveq #20,d1
bsr DrawText
move.l CurrentEmail,a0
move.l 18(a0),a0 ; Opt2
moveq #2,d0
moveq #22,d1
bsr DrawText
.done:
rts
UpdateGame:
move.b GameState,d0
cmp.b #STATE_TITLE,d0
beq UpdateTitle
cmp.b #STATE_PLAYING,d0
beq UpdatePlaying
cmp.b #STATE_GAMEOVER,d0
beq UpdateGameOver
rts
UpdateTitle:
; Check for Space or Return to start
; For now, auto-start
bsr StartGame
rts
UpdatePlaying:
; 1. Check Win/Loss
move.b Stress,d0
cmp.b #MAX_STRESS,d0
bge SetGameOver
move.b Satisfaction,d0
beq SetGameOver
move.w GameTime,d0
cmp.w #END_TIME,d0
bge SetGameOver
; 2. Check Input for Options
move.b LastKey,d0
cmp.b #0,d0
beq .noInput
; Clear LastKey immediately to prevent re-processing
move.b #0,LastKey
; Check '1' and '2' keys
; Amiga raw keycodes: '1' = $01, '2' = $02
cmp.b #$01,d0 ; '1'
beq .opt1
cmp.b #$02,d0 ; '2'
beq .opt2
bra .noInput
.opt1:
; Apply effects
; TODO: Read effects from CurrentEmail
bsr NextEmail
bra .noInput
.opt2:
bsr NextEmail
bra .noInput
.noInput:
; 3. Update Time
addq.w #1,FrameCounter
cmp.w #250,FrameCounter
blt.s .noTimeUpdate
move.w #0,FrameCounter
addq.w #1,GameTime
.noTimeUpdate:
rts
NextEmail:
; Clear screen area (or full screen)
bsr ClearScreen
bsr SpawnEmail
rts
UpdateGameOver:
; Wait for restart
rts
SetGameOver:
move.b #STATE_GAMEOVER,GameState
rts
; SECTION Data,DATA_C
GameState: dc.b 0
Stress: dc.b 0
Satisfaction: dc.b 0
ALIGN 2
GameTime: dc.w 0
EmailCount: dc.w 0
FrameCounter: dc.w 0
CurrentEmail: dc.l 0