GSCats/loadingBar.s

141 lines
2.5 KiB
ArmAsm
Raw Normal View History

2023-07-20 20:40:38 +00:00
;
; loadingBar
; A simple GUI element to show loading progress
;
; Created by Quinn Dunki on 7/20/23
;
BORDER = $FF
2023-07-21 02:41:06 +00:00
BORDERL = $1F
BORDERR = $F1
2023-07-20 20:40:38 +00:00
FILL = $22
EMPTY = $ee
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; advanceLoadingBar
;
; A = Bytes to advance
;
; Trashes SCRATCHL
;
advanceLoadingBar:
sta SCRATCHL
lda currentLoadingBar+CBR_CURRENT
clc
adc SCRATCHL
cmp currentLoadingBar+CBR_FINAL
beq advanceLoadingBarDone
bcs advanceLoadingBarClamp
advanceLoadingBarDone:
sta currentLoadingBar+CBR_CURRENT
rts
advanceLoadingBarClamp:
lda currentLoadingBar+CBR_FINAL
bra advanceLoadingBarDone
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderLoadingBar
;
; Not very fast
;
renderLoadingBar:
SAVE_AXY
ldy #0
ldx currentLoadingBar+CBR_VRAM
BITS8A
2023-07-20 21:42:22 +00:00
lda #BORDERL ; Left border
2023-07-20 20:40:38 +00:00
sta VRAMBANK,x
sta VRAMBANK+160,x
sta VRAMBANK+160*2,x
sta VRAMBANK+160*3,x
sta VRAMBANK+160*4,x
sta VRAMBANK+160*5,x
sta VRAMBANK+160*6,x
sta VRAMBANK+160*7,x
sta VRAMBANK+160*8,x
sta VRAMBANK+160*9,x
sta VRAMBANK+160*10,x
sta VRAMBANK+160*11,x
sta VRAMBANK+160*12,x
sta VRAMBANK+160*13,x
sta VRAMBANK+160*14,x
sta VRAMBANK+160*15,x
inx
renderLoadingBarLoop:
lda #BORDER
sta VRAMBANK,x ; Top border
sta VRAMBANK+160*15,x ; Bottom border
cpy currentLoadingBar+CBR_CURRENT
bcc renderLoadingBarFillReady
jmp renderLoadingBarEmpty
renderLoadingBarFillReady:
lda #FILL
renderLoadingBarFill:
sta VRAMBANK+160*1,x ; Bar
sta VRAMBANK+160*2,x
sta VRAMBANK+160*3,x
sta VRAMBANK+160*4,x
sta VRAMBANK+160*5,x
sta VRAMBANK+160*6,x
sta VRAMBANK+160*7,x ; Bar
sta VRAMBANK+160*8,x
sta VRAMBANK+160*9,x
sta VRAMBANK+160*10,x
sta VRAMBANK+160*11,x
sta VRAMBANK+160*12,x
sta VRAMBANK+160*13,x
sta VRAMBANK+160*14,x
inx
iny
cpy currentLoadingBar+CBR_FINAL
bne renderLoadingBarLoop
2023-07-20 21:42:22 +00:00
lda #BORDERR ; Right border
2023-07-20 20:40:38 +00:00
sta VRAMBANK,x
sta VRAMBANK+160,x
sta VRAMBANK+160*2,x
sta VRAMBANK+160*3,x
sta VRAMBANK+160*4,x
sta VRAMBANK+160*5,x
sta VRAMBANK+160*6,x
sta VRAMBANK+160*7,x
sta VRAMBANK+160*8,x
sta VRAMBANK+160*9,x
sta VRAMBANK+160*10,x
sta VRAMBANK+160*11,x
sta VRAMBANK+160*12,x
sta VRAMBANK+160*13,x
sta VRAMBANK+160*14,x
sta VRAMBANK+160*15,x
BITS16
RESTORE_AXY
rts
renderLoadingBarEmpty:
.a8
lda #EMPTY
jmp renderLoadingBarFill
CBR_ACTIVE = 0
CBR_CURRENT = 2
CBR_FINAL = 4
CBR_VRAM = 6
currentLoadingBar:
.word 0 ; Active
.word 0 ; Current progress in bytes
2023-07-23 21:59:55 +00:00
.word 66 ; Final progress in bytes
2023-07-20 20:40:38 +00:00
.word $5eb4 ; VRAM position (top left)