Skip to content

Commit

Permalink
Status of bars in Indiana is closed
Browse files Browse the repository at this point in the history
Per https://backontrack.in.gov/ Indiana plans to reopen bars and
nightclubs on June 14 provided COVID-19 doesn't flare up again.
  • Loading branch information
pinobatch committed May 3, 2020
1 parent 2fb8098 commit f2a60e3
Show file tree
Hide file tree
Showing 8 changed files with 332 additions and 4 deletions.
23 changes: 23 additions & 0 deletions hopesup/hope.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Hope is confidence in a positive outcome.

1. load in-game palette
2.
3. CHR for floor
4. nametable for predefined floor
5. CHR for walls
6. nametable for walls
7. CHR for sprite
8. sprite moves
9. valid movement only
10. floor generation
11. count score
12. exit door
13. animate rolling
14. fall
15. instruction screen
16. fades
17. attract mode
18.
19. audio
20. count combo

7 changes: 4 additions & 3 deletions hopesup/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
title:=hopesup
version:=wip
objlist:= \
init main ppuclear pads vwfdraw vwf7_cp144p
init main statusbar floorvram floormodel \
bcd ppuclear pads vwfdraw vwf7_cp144p

objdir:=obj/something
srcdir:=src
Expand Down Expand Up @@ -80,8 +81,8 @@ $(objdir)/%-gg.o: $(objdir)/%.asm $(srcdir)/sms.inc

# Additional deps (.include/.incbin)

$(objdir)/bg.o $(objdir)/bg-gg.o: \
$(objdir)/title.iu
$(objdir)/statusbar.o: \
$(objdir)/16x16digits1616.2b

# Linking

Expand Down
100 changes: 100 additions & 0 deletions hopesup/src/bcd.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
;
; Binary to decimal (8-bit)
; Copyright 2018 Damian Yerrick
;
; This software is provided 'as-is', without any express or implied
; warranty. In no event will the authors be held liable for any damages
; arising from the use of this software.
;
; Permission is granted to anyone to use this software for any purpose,
; including commercial applications, and to alter it and redistribute it
; freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must not
; claim that you wrote the original software. If you use this software
; in a product, an acknowledgment in the product documentation would be
; appreciated but is not required.
; 2. Altered source versions must be plainly marked as such, and must not be
; misrepresented as being the original software.
; 3. This notice may not be removed or altered from any source distribution.
;
.include "src/sms.inc"

.section "bcd" free

;;
; Converts an 8-bit value to decimal.
; @param A the value
; @return A: tens and ones digits; B[1:0]: hundreds digit;
; B[7:2]: unspecified
bcd8bit_baa:

rrca
rrca
rrca
rrca
ld b,a
and $0F ; bits 3-0 in A, range $00-$0F
or a ; for some odd reason, AND sets half carry to 1
daa ; A=$00-$15

sla b
adc a
daa
sla b
adc a
daa ; A=$00-$63
rl b
adc a
daa
rl b
adc a
daa
rl b
ret

;;
; Calculates one digit of converting a fraction to a percentage.
; @param B numerator, less than C
; @param C denominator, greater than 0
; @return A = floor(10 * B / C); B = 10 * B % C;
; CHL unchanged; D clobbered; E = 0
pctdigit:
ld de,$1000

; bit 3: A.E = B * 1.25
ld a,b
srl a
rr e
srl a
rr e
add b
jr @have_first_carry

; bits 2-0: mul A.E by 2
@bitloop:
rl e
adc a
@have_first_carry:
jr c,@yessub
cp c
jr c,@nosub
@yessub:
; Usually A>=C so subtracting C won't borrow. But if we
; arrived via yessub, A>256 so even though 256+A>=C, A<C.
sub c
or a
@nosub:
rl d
jr nc,@bitloop

ld b,a
; Binary to decimal subtracts if trial subtraction has no borrow.
; 6502/ARM carry: 0: borrow; 1: no borrow
; 8080 carry: 1: borrow; 0: borrow
; The 6502 interpretation is more convenient for binary to decimal
; conversion, so convert to 6502 discipline
ld a,$0F
xor d
ret
.ends
11 changes: 11 additions & 0 deletions hopesup/src/floorvram.asm
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
.include "src/sms.inc"

; In-game VRAM map
; $4000 color 0, not hole
; $4180 color 0, is hole
; $4300 color 0 arrows
; $4400-$4FFF same for colors 1-3
; $5000 floor border (up to 64 tiles I guess)
; $5800 status bar
; $6000 sprites?
; $7800 nametable
; $7F00 SAT
11 changes: 10 additions & 1 deletion hopesup/src/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ sat_xn ds NUM_SPRITES*2
; consoles that use NMI for vertical blank.
nmis db
pause_pressed db
debughex0 db
debughex1 db
cur_score db
max_score db
cur_combo db
.ends

.bank 0 slot 0
Expand Down Expand Up @@ -151,11 +156,15 @@ draw_bg:
ld hl, lineImgBuf
ld d, 1
call load_1bpp_font
call load_status_chr
call init_status_bar
; call draw_debughex

ret

PaletteData:
drgb $AAAAAA, $000000
drgb $000000,$555555,$AAAAAA,$FFFFFF
PaletteDataEnd:
hello_msg:
.db "Nothing to see; move along", 0
Expand Down
184 changes: 184 additions & 0 deletions hopesup/src/statusbar.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
.include "src/sms.inc"

.def STATUS_FIRST_TILE $C0
.def STATUS_BIG_DIGITS $C0
.def STATUS_BLANK_TILE $EC
.def STATUS_SLASH_TILE $EE
.def STATUS_M_TILE $EF
.def STATUS_SMALL_DIGITS $F0

.section "statuschr" free
digits_chr:
.incbin "obj/something/16x16digits1616.2b"
.ends

.section "statusbar" free

load_status_chr:
vdp_seek_tile $C0
ld hl, digits_chr
ld b, 0
ld d, >identity_table
ld ix, 0
call load_2bpp_cel
call load_2bpp_cel

; TODO: Color the status bar
ret

init_status_bar:
ld hl, debughex0
ld [hl], $C0
inc hl
ld [hl], $DE

; Set background
vdp_seek_xy 0, 22
ld b, 64
@clrloop:
ld a, STATUS_BLANK_TILE
out [VDPDATA], a
xor a
out [VDPDATA], a
djnz @clrloop

; Write "Combo"
vdp_seek_xy 6, 23
ld a, $C0
call put2digsm
ld a, STATUS_M_TILE
call put1tileid
ld a, $B0
call put2digsm

; Percent sign
ld l, <(18 * 2 + 22 * 64)
ld a, 10
call put1digbig
ld a, 69
ld [max_score], a
ld a, 5
ld [cur_combo], a
ld a, 6
ld [cur_score], a

; Write level maximum score
vdp_seek_xy 27, 23
ld a, STATUS_SLASH_TILE
call put1tileid
ld a, [max_score]
call bcd8bit_baa
call put2digsm

update_status_bar:

ld a, [max_score]
ld c, a
ld a, [cur_score]
cp c
jr c, @not_100pct
ld l, <(12 * 2 + 22 * 64)
ld a, $10
call put2digbig
xor a
jr @have_last_pctdigit
@not_100pct:
ld b, a
call pctdigit
ld l, <(14 * 2 + 22 * 64)
or a
jr nz, @atleast10pct
ld a, 11
@atleast10pct:
call put1digbig
call pctdigit
@have_last_pctdigit:
call put1digbig

ld l, <(2 * 2 + 22 * 64)
ld a, 5
call put2decdigbig
ld l, <(23 * 2 + 22 * 64)
ld a, 15
put2decdigbig:
call bcd8bit_baa
put2digbig:
ld c, a
and $F0
jr nz, @yes_tens
ld a, 11
jr @have_tens_digit
@yes_tens:
ld a, c
and $F0
rrca
rrca
rrca
rrca
@have_tens_digit:
call put1digbig
ld a, c
and $0F
put1digbig:
; may trash ABDEH, must add 2 to L
add a
add a
or STATUS_BIG_DIGITS
ld h, a

ld a, l ; Top row
call @puttileb
ld a, l ; Bottomrow
inc l
inc l
inc l
inc l
add 64
@puttileb:
out [VDPCTRL], a
ld a, $7D
out [VDPCTRL], a
ld a, h
out [VDPDATA], a
cp STATUS_BLANK_TILE
ld a, 0
nop
out [VDPDATA], a
nop
jr nc, @isblank1
inc h
@isblank1:
ld a, h
out [VDPDATA], a
ld a, 0
jr nc, @isblank2
inc h
@isblank2:
out [VDPDATA], a
ret
.ends

draw_debughex:
vdp_seek_xy 7, 22
ld a, [debughex0]
call put2digsm
ld a, [debughex1]
put2digsm:
push af
rrca
rrca
rrca
rrca
call put1dig
pop af
put1dig:
or STATUS_SMALL_DIGITS
put1tileid:
out [VDPDATA], a
xor a
nop
nop
nop
out [VDPDATA], a
ret
Binary file modified hopesup/tilesets/16x16digits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed hopesup/tilesets/otherstatustiles.png
Binary file not shown.

0 comments on commit f2a60e3

Please sign in to comment.