Skip to content

Commit

Permalink
yay, iu53 works
Browse files Browse the repository at this point in the history
  • Loading branch information
pinobatch committed Jul 13, 2018
1 parent 25414d1 commit 4606ec2
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,6 +11,7 @@
*.iu53
/nes/obj/nes/*.s
/nes/obj/nes/*.sav
/nes/new-linearity/obj/nes/*.sav
/gameboy/obj/gb/*.z80
/gameboy/obj/gb/*.nam
/gameboy/obj/gb/*.iu
Expand Down
14 changes: 8 additions & 6 deletions nes/new-linearity/makefile
Expand Up @@ -50,8 +50,8 @@ $(objdir)/index.txt: makefile
echo "Files produced by build tools go here, but caulk goes where?" > $@

clean:
-rm $(objdir)/*.o $(objdir)/*.s $(objdir)/*.chr $(objdir)/*.?b53
-rm $(objdir)/*.sav map.txt bnmap.txt
-rm $(objdir)/*.o $(objdir)/*.s $(objdir)/*.chr $(objdir)/*.iu53
-rm $(objdir)/*.sav map.txt

# Rules for PRG ROM

Expand All @@ -66,15 +66,17 @@ $(objdir)/%.o: $(srcdir)/%.s $(srcdir)/nes.inc $(srcdir)/global.inc
$(objdir)/%.o: $(objdir)/%.s
$(AS65) $(CFLAGS65) $< -o $@

# extra dependencies
# included things

$(objdir)/main.o: $(objdir)/linearity_ntsc.iu53 $(objdir)/linearity_pal.iu53

# graphics rules

$(objdir)/linearity_ntsc.iu53: $(objdir)/linearity_ntscgray.sav
echo want to compress $< to $@ with 7x1 bg pattern
$(PY) ../tools/sav2iu53.py --x-grid 0,1,2,3,4,5,6 $< $@

$(objdir)/linearity_pal.iu53: $(objdir)/linearity_palgray.sav
echo want to compress $< to $@ with 1x11 bg pattern
$(PY) ../tools/sav2iu53.py --y-grid 8,2,5,8,0,3,6,8,1,4,7 $< $@

$(objdir)/%gray.sav: $(imgdir)/%.png
$(PY) tools/savtool.py --palette 0f0010200f1616160f1616160f161616 $< $@
$(PY) ../tools/savtool.py --palette 0f0010200f1616160f1616160f161616 $< $@
2 changes: 1 addition & 1 deletion nes/new-linearity/src/global.inc
Expand Up @@ -15,4 +15,4 @@

; uniu.s
.globalzp uniu_width, uniu_height, uniu_seen_tiles, uniu_first_nonblank
.global uniu
.global uniu, uniu_file_ay, uniu_file
11 changes: 11 additions & 0 deletions nes/new-linearity/src/main.s
Expand Up @@ -32,10 +32,21 @@ nmis: .res 1
ldy #$00
ldx #$24
jsr ppu_clear_nt

sta $4444
lda #>linearity_ntsc_iu53
ldy #<linearity_ntsc_iu53
jsr uniu_file_ay
ldx #$00
ldy #$00
lda #VBLANK_NMI|BG_0000
jsr ppu_screen_on
forever:
jmp forever
.endproc

.rodata
linearity_ntsc_iu53:
.incbin "obj/nes/linearity_ntsc.iu53"
linearity_pal_iu53:
.incbin "obj/nes/linearity_pal.iu53"
103 changes: 102 additions & 1 deletion nes/new-linearity/src/uniu.s
Expand Up @@ -66,6 +66,7 @@ uniu_seen_tiles = $07
sta PPUADDR
clc
adc #32
sta ciDst+0
bcc :+
inc ciDst+1
:
Expand Down Expand Up @@ -115,4 +116,104 @@ uniu_seen_tiles = $07
bne rowloop
sty ciSrc+0
rts
.endproc
.endproc

.proc add_a_to_ciSrc
clc
adc ciSrc
sta ciSrc
bcc :+
inc ciSrc+1
:
rts
.endproc

.proc uniu_file_ay
sta ciSrc+1
sty ciSrc
.endproc
.proc uniu_file
; Header before the PB53 tile data:
; Tile number of first nonblank tile, number of PB53 tiles

; Get the address of the first nonblank tile
ldy #0
lda (ciSrc),y
pha ; Stack: first nonblank tile, ...
asl a ; multiply by 16
sta ciDst
tya
rol a
asl ciDst
rol a
asl ciDst
rol a
asl ciDst
rol a
sta PPUADDR
lda ciDst
sta PPUADDR

; Get the pb53 tile count
iny
lda (ciSrc),y
tax

; Skip the header so far
lda #2
jsr add_a_to_ciSrc
jsr unpb53_xtiles
pla
sta uniu_first_nonblank

; Header after PB53 tile data:
; starting NT address (2 bytes), width, height
ldy #0
lda (ciSrc),y
sta ciDst+0
iny
lda (ciSrc),y
pha ; save address which has flags in bits 7-6
and #$2F
sta ciDst+1
iny
lda (ciSrc),y
sta uniu_width
iny
lda (ciSrc),y
sta uniu_height
lda #4
jsr add_a_to_ciSrc
jsr uniu
pla ; A = flags saved earlier

; Optionally, attributes and palette can follow
asl a
bcc no_attributes
pha ; save other flag
lda ciDst+1
ora #$03 ; skip to attribute table
sta PPUADDR
lda #$C0
sta PPUADDR
ldx #64/16
jsr unpb53_xtiles
pla
no_attributes:

ldy #$00
asl a
bcc no_palette
lda #$3F
sta PPUADDR
sty PPUADDR
palloop:
lda (ciSrc),y
sta PPUDATA
iny
cpy #16
bcc palloop
no_palette:

rts
.endproc
2 changes: 1 addition & 1 deletion nes/new-linearity/src/unpb53.s
Expand Up @@ -8,7 +8,7 @@
; code copies. This file is offered as-is, without any warranty.
;
.include "nes.inc"
.export unpb53_some;, unpb53_file_cb, load_sb53_file_cb
.export unpb53_some, unpb53_xtiles;, unpb53_file_cb, load_sb53_file_cb
.import unpb53_files, sb53_files
.export PB53_outbuf
.exportzp ciSrc, ciDst, ciBufStart, ciBufEnd
Expand Down
4 changes: 2 additions & 2 deletions nes/src/unpb53.s
Expand Up @@ -8,10 +8,10 @@
; code copies. This file is offered as-is, without any warranty.
;
.include "nes.inc"
.export unpb53_some, unpb53_file_cb, load_sb53_file_cb
.export unpb53_some, unpb53_xtiles, unpb53_file_cb, load_sb53_file_cb
.import unpb53_files, sb53_files
.export PB53_outbuf
.exportzp ciSrc, ciSrc, ciBufStart, ciBufEnd
.exportzp ciSrc, ciDst, ciBufStart, ciBufEnd
.importzp nmis

.segment "ZEROPAGE"
Expand Down
6 changes: 4 additions & 2 deletions nes/tools/linearityconv.py → nes/tools/sav2iu53.py
Expand Up @@ -253,5 +253,7 @@ def main(argv=None):
" ../new-linearity/obj/nes/test_pal.iu53"
" --y-grid 8,2,5,8,0,3,6,8,1,4,7 -v",
]
for job in jobs:
main(job.split())
if __name__=='__main__':
## for job in jobs:
## main(job.split())
main()

0 comments on commit 4606ec2

Please sign in to comment.