Removed (pretty inconsistently used) tab chars from source code base.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
../tgi/nes-64-56-2.tgi: ../wrk/nes/clrscr.o \
|
||||
../tgi/nes-64-56-2.tgi: ../wrk/nes/clrscr.o \
|
||||
../wrk/nes/cputc.o \
|
||||
../wrk/nes/get_tv.o \
|
||||
../wrk/nes/gotoxy.o \
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
; Screen size function
|
||||
;
|
||||
|
||||
.export screensize
|
||||
.export screensize
|
||||
|
||||
.include "nes.inc"
|
||||
.include "get_tv.inc"
|
||||
.include "nes.inc"
|
||||
.include "get_tv.inc"
|
||||
|
||||
|
||||
.proc screensize
|
||||
.proc screensize
|
||||
|
||||
jsr _get_tv
|
||||
ldx #charsperline
|
||||
ldy #screenrows
|
||||
cmp #TV::PAL
|
||||
beq pal
|
||||
dey ; NTSC rows
|
||||
pal: rts
|
||||
jsr _get_tv
|
||||
ldx #charsperline
|
||||
ldy #screenrows
|
||||
cmp #TV::PAL
|
||||
beq pal
|
||||
dey ; NTSC rows
|
||||
pal: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -5,25 +5,25 @@
|
||||
; void cclear (unsigned char length);
|
||||
;
|
||||
|
||||
.export _cclearxy, _cclear
|
||||
.import popa, _gotoxy, cputdirect
|
||||
.importzp tmp1
|
||||
.export _cclearxy, _cclear
|
||||
.import popa, _gotoxy, cputdirect
|
||||
.importzp tmp1
|
||||
|
||||
_cclearxy:
|
||||
pha ; Save the length
|
||||
jsr popa ; Get y
|
||||
jsr _gotoxy ; Call this one, will pop params
|
||||
pla ; Restore the length and run into _cclear
|
||||
pha ; Save the length
|
||||
jsr popa ; Get y
|
||||
jsr _gotoxy ; Call this one, will pop params
|
||||
pla ; Restore the length and run into _cclear
|
||||
|
||||
_cclear:
|
||||
cmp #0 ; Is the length zero?
|
||||
beq L9 ; Jump if done
|
||||
sta tmp1
|
||||
L1: lda #$20 ; Blank - screen code
|
||||
jsr cputdirect ; Direct output
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
cmp #0 ; Is the length zero?
|
||||
beq L9 ; Jump if done
|
||||
sta tmp1
|
||||
L1: lda #$20 ; Blank - screen code
|
||||
jsr cputdirect ; Direct output
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,27 +5,27 @@
|
||||
; void chline (unsigned char length);
|
||||
;
|
||||
|
||||
.export _chlinexy, _chline
|
||||
.import popa, _gotoxy, cputdirect
|
||||
.importzp tmp1
|
||||
.export _chlinexy, _chline
|
||||
.import popa, _gotoxy, cputdirect
|
||||
.importzp tmp1
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
_chlinexy:
|
||||
pha ; Save the length
|
||||
jsr popa ; Get y
|
||||
jsr _gotoxy ; Call this one, will pop params
|
||||
pla ; Restore the length
|
||||
pha ; Save the length
|
||||
jsr popa ; Get y
|
||||
jsr _gotoxy ; Call this one, will pop params
|
||||
pla ; Restore the length
|
||||
|
||||
_chline:
|
||||
cmp #0 ; Is the length zero?
|
||||
beq L9 ; Jump if done
|
||||
sta tmp1
|
||||
L1: lda #CH_HLINE ; Horizontal line, screen code
|
||||
jsr cputdirect ; Direct output
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
cmp #0 ; Is the length zero?
|
||||
beq L9 ; Jump if done
|
||||
sta tmp1
|
||||
L1: lda #CH_HLINE ; Horizontal line, screen code
|
||||
jsr cputdirect ; Direct output
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,20 +12,20 @@
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
.export _clock
|
||||
.importzp sreg
|
||||
.export _clock
|
||||
.importzp sreg
|
||||
|
||||
|
||||
.proc _clock
|
||||
.proc _clock
|
||||
|
||||
ldy #0 ; High word is always zero
|
||||
sty sreg+1
|
||||
sty sreg
|
||||
ldy #0 ; High word is always zero
|
||||
sty sreg+1
|
||||
sty sreg
|
||||
L1: ldx tickcount+1
|
||||
lda tickcount
|
||||
cpx tickcount+1 ; Did tickcount change?
|
||||
bne L1 ; Yes, re-read it
|
||||
rts
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
; void clrscr (void);
|
||||
;
|
||||
|
||||
.export _clrscr
|
||||
.import ppubuf_waitempty
|
||||
.export _clrscr
|
||||
.import ppubuf_waitempty
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
; wait for vblank
|
||||
|
||||
lda #0
|
||||
lda #0
|
||||
sta VBLANK_FLAG
|
||||
@w2: lda VBLANK_FLAG
|
||||
beq @w2
|
||||
@@ -27,7 +27,7 @@
|
||||
; switch screen off
|
||||
|
||||
lda #%00000000
|
||||
sta PPU_CTRL2
|
||||
sta PPU_CTRL2
|
||||
|
||||
; Set start address to Name Table #1
|
||||
|
||||
@@ -64,8 +64,8 @@ lll: lda #$00 ; Write attribute table value and auto increment
|
||||
; switch screen on again
|
||||
|
||||
lda #%00011110
|
||||
sta PPU_CTRL2
|
||||
rts
|
||||
sta PPU_CTRL2
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -8,62 +8,62 @@
|
||||
;
|
||||
|
||||
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
.import return0, ppubuf_put
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
.import return0, ppubuf_put
|
||||
|
||||
.include "nes.inc"
|
||||
.include "nes.inc"
|
||||
|
||||
_textcolor = return0
|
||||
_bordercolor = return0
|
||||
|
||||
.proc _bgcolor
|
||||
|
||||
tax
|
||||
lda BGCOLOR ; get old value
|
||||
stx BGCOLOR ; set new value
|
||||
pha
|
||||
tax
|
||||
lda BGCOLOR ; get old value
|
||||
stx BGCOLOR ; set new value
|
||||
pha
|
||||
|
||||
lda colors,x
|
||||
pha
|
||||
ldy #$3F
|
||||
ldx #0
|
||||
jsr ppubuf_put
|
||||
pla
|
||||
pha
|
||||
ldy #$3F
|
||||
ldx #4
|
||||
jsr ppubuf_put
|
||||
pla
|
||||
pha
|
||||
ldy #$3F
|
||||
ldx #8
|
||||
jsr ppubuf_put
|
||||
pla
|
||||
ldy #$3F
|
||||
ldx #12
|
||||
jsr ppubuf_put
|
||||
lda colors,x
|
||||
pha
|
||||
ldy #$3F
|
||||
ldx #0
|
||||
jsr ppubuf_put
|
||||
pla
|
||||
pha
|
||||
ldy #$3F
|
||||
ldx #4
|
||||
jsr ppubuf_put
|
||||
pla
|
||||
pha
|
||||
ldy #$3F
|
||||
ldx #8
|
||||
jsr ppubuf_put
|
||||
pla
|
||||
ldy #$3F
|
||||
ldx #12
|
||||
jsr ppubuf_put
|
||||
|
||||
pla
|
||||
rts
|
||||
pla
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
.rodata
|
||||
|
||||
colors: .byte $0f ; 0 black
|
||||
.byte $3d ; 1 white
|
||||
.byte $04 ; 2 red
|
||||
.byte $3b ; 3 cyan
|
||||
.byte $14 ; 4 violett
|
||||
.byte $1a ; 5 green
|
||||
.byte $01 ; 6 blue
|
||||
.byte $38 ; 7 yellow
|
||||
.byte $18 ; 8 orange
|
||||
.byte $08 ; 9 brown
|
||||
.byte $35 ; a light red
|
||||
.byte $2d ; b dark grey
|
||||
.byte $10 ; c middle grey
|
||||
.byte $2b ; d light green
|
||||
.byte $22 ; e light blue
|
||||
.byte $3d ; f light gray
|
||||
.byte $3d ; 1 white
|
||||
.byte $04 ; 2 red
|
||||
.byte $3b ; 3 cyan
|
||||
.byte $14 ; 4 violett
|
||||
.byte $1a ; 5 green
|
||||
.byte $01 ; 6 blue
|
||||
.byte $38 ; 7 yellow
|
||||
.byte $18 ; 8 orange
|
||||
.byte $08 ; 9 brown
|
||||
.byte $35 ; a light red
|
||||
.byte $2d ; b dark grey
|
||||
.byte $10 ; c middle grey
|
||||
.byte $2b ; d light green
|
||||
.byte $22 ; e light blue
|
||||
.byte $3d ; f light gray
|
||||
|
||||
|
||||
@@ -6,73 +6,73 @@
|
||||
; void cputc (char c);
|
||||
;
|
||||
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline
|
||||
.constructor initconio
|
||||
.import popa, _gotoxy
|
||||
.import popa, _gotoxy
|
||||
.import ppuinit, paletteinit, ppubuf_put
|
||||
.import setcursor
|
||||
|
||||
.importzp tmp3,tmp4
|
||||
|
||||
.include "nes.inc"
|
||||
.include "nes.inc"
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
.code
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
_cputc: cmp #$0d ; CR?
|
||||
bne L1
|
||||
lda #0
|
||||
sta CURS_X
|
||||
beq plot ; Recalculate pointers
|
||||
_cputc: cmp #$0d ; CR?
|
||||
bne L1
|
||||
lda #0
|
||||
sta CURS_X
|
||||
beq plot ; Recalculate pointers
|
||||
|
||||
L1: cmp #$0a ; LF?
|
||||
beq newline ; Recalculate pointers
|
||||
L1: cmp #$0a ; LF?
|
||||
beq newline ; Recalculate pointers
|
||||
|
||||
; Printable char of some sort
|
||||
|
||||
cputdirect:
|
||||
jsr putchar ; Write the character to the screen
|
||||
jsr putchar ; Write the character to the screen
|
||||
|
||||
; Advance cursor position
|
||||
|
||||
advance:
|
||||
ldy CURS_X
|
||||
iny
|
||||
cpy #xsize
|
||||
bne L3
|
||||
inc CURS_Y ; new line
|
||||
ldy #0 ; + cr
|
||||
L3: sty CURS_X
|
||||
jmp plot
|
||||
ldy CURS_X
|
||||
iny
|
||||
cpy #xsize
|
||||
bne L3
|
||||
inc CURS_Y ; new line
|
||||
ldy #0 ; + cr
|
||||
L3: sty CURS_X
|
||||
jmp plot
|
||||
|
||||
newline:
|
||||
inc CURS_Y
|
||||
inc CURS_Y
|
||||
|
||||
; Set cursor position, calculate RAM pointers
|
||||
|
||||
plot: ldy CURS_X
|
||||
ldx CURS_Y
|
||||
jmp setcursor ; Set the new cursor
|
||||
plot: ldy CURS_X
|
||||
ldx CURS_Y
|
||||
jmp setcursor ; Set the new cursor
|
||||
|
||||
|
||||
; Write one character to the screen without doing anything else, return X
|
||||
; position in Y
|
||||
|
||||
putchar:
|
||||
ora RVS ; Set revers bit
|
||||
ora RVS ; Set revers bit
|
||||
ldy SCREEN_PTR+1
|
||||
ldx SCREEN_PTR
|
||||
jmp ppubuf_put
|
||||
ldx SCREEN_PTR
|
||||
jmp ppubuf_put
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; Initialize the conio subsystem. Code goes into the INIT segment, which may
|
||||
@@ -82,12 +82,12 @@ putchar:
|
||||
|
||||
initconio:
|
||||
jsr ppuinit
|
||||
jsr paletteinit
|
||||
jsr paletteinit
|
||||
|
||||
lda #0
|
||||
sta RVS
|
||||
sta CURS_X
|
||||
sta CURS_Y
|
||||
lda #0
|
||||
sta RVS
|
||||
sta CURS_X
|
||||
sta CURS_Y
|
||||
|
||||
jmp plot ; Set the cursor
|
||||
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
|
||||
.export _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
.import initlib, donelib, callmain
|
||||
.import push0, _main, zerobss, copydata
|
||||
.import initlib, donelib, callmain
|
||||
.import push0, _main, zerobss, copydata
|
||||
.import ppubuf_flush
|
||||
|
||||
; Linker generated symbols
|
||||
.import __RAM_START__, __RAM_SIZE__
|
||||
.import __SRAM_START__, __SRAM_SIZE__
|
||||
.import __ROM0_START__, __ROM0_SIZE__
|
||||
.import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__
|
||||
.import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__
|
||||
.import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__
|
||||
.import __RAM_START__, __RAM_SIZE__
|
||||
.import __SRAM_START__, __SRAM_SIZE__
|
||||
.import __ROM0_START__, __ROM0_SIZE__
|
||||
.import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__
|
||||
.import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__
|
||||
.import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "nes.inc"
|
||||
.include "nes.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -55,18 +55,18 @@
|
||||
; | ..-EOF | | CHR-ROM pages (in ascending order). |
|
||||
; +--------+------+------------------------------------------+
|
||||
|
||||
.byte $4e,$45,$53,$1a ; "NES"^Z
|
||||
.byte 2 ; ines prg - Specifies the number of 16k prg banks.
|
||||
.byte 1 ; ines chr - Specifies the number of 8k chr banks.
|
||||
.byte %00000011 ; ines mir - Specifies VRAM mirroring of the banks.
|
||||
.byte %00000000 ; ines map - Specifies the NES mapper used.
|
||||
.byte 0,0,0,0,0,0,0,0 ; 8 zeroes
|
||||
.byte $4e,$45,$53,$1a ; "NES"^Z
|
||||
.byte 2 ; ines prg - Specifies the number of 16k prg banks.
|
||||
.byte 1 ; ines chr - Specifies the number of 8k chr banks.
|
||||
.byte %00000011 ; ines mir - Specifies VRAM mirroring of the banks.
|
||||
.byte %00000000 ; ines map - Specifies the NES mapper used.
|
||||
.byte 0,0,0,0,0,0,0,0 ; 8 zeroes
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Place the startup code in a special segment.
|
||||
|
||||
.segment "STARTUP"
|
||||
.segment "STARTUP"
|
||||
|
||||
start:
|
||||
|
||||
@@ -74,51 +74,51 @@ start:
|
||||
|
||||
sei
|
||||
cld
|
||||
ldx #0
|
||||
stx VBLANK_FLAG
|
||||
ldx #0
|
||||
stx VBLANK_FLAG
|
||||
|
||||
stx ringread
|
||||
stx ringwrite
|
||||
stx ringcount
|
||||
stx ringread
|
||||
stx ringwrite
|
||||
stx ringcount
|
||||
|
||||
txs
|
||||
|
||||
lda #$20
|
||||
@l: sta ringbuff,x
|
||||
sta ringbuff+$0100,x
|
||||
sta ringbuff+$0200,x
|
||||
sta ringbuff+$0100,x
|
||||
sta ringbuff+$0200,x
|
||||
inx
|
||||
bne @l
|
||||
bne @l
|
||||
|
||||
; Clear the BSS data
|
||||
|
||||
jsr zerobss
|
||||
jsr zerobss
|
||||
|
||||
; initialize data
|
||||
jsr copydata
|
||||
jsr copydata
|
||||
|
||||
; setup the stack
|
||||
|
||||
lda #<(__SRAM_START__ + __SRAM_SIZE__)
|
||||
sta sp
|
||||
lda #>(__SRAM_START__ + __SRAM_SIZE__)
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
sta sp
|
||||
lda #>(__SRAM_START__ + __SRAM_SIZE__)
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
|
||||
; Call module constructors
|
||||
|
||||
jsr initlib
|
||||
jsr initlib
|
||||
|
||||
; Push arguments and call main()
|
||||
|
||||
jsr callmain
|
||||
jsr callmain
|
||||
|
||||
; Call module destructors. This is also the _exit entry.
|
||||
|
||||
_exit: jsr donelib ; Run module destructors
|
||||
_exit: jsr donelib ; Run module destructors
|
||||
|
||||
; Reset the NES
|
||||
|
||||
jmp start
|
||||
jmp start
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; System V-Blank Interupt
|
||||
@@ -175,8 +175,8 @@ irq:
|
||||
.word irq1 ; $fff6 ?
|
||||
.word timerirq ; $fff8 ?
|
||||
.word nmi ; $fffa vblank nmi
|
||||
.word start ; $fffc reset
|
||||
.word irq ; $fffe irq / brk
|
||||
.word start ; $fffc reset
|
||||
.word irq ; $fffe irq / brk
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; character data
|
||||
|
||||
@@ -33,140 +33,140 @@
|
||||
; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v')
|
||||
; 7 - Space or tab character
|
||||
|
||||
.export __ctype
|
||||
.export __ctype
|
||||
|
||||
__ctype:
|
||||
|
||||
.repeat 2 ; 2 times for normal and inverted
|
||||
|
||||
.byte $10 ; 0/00 ___ctrl_@___
|
||||
.byte $10 ; 1/01 ___ctrl_A___
|
||||
.byte $10 ; 2/02 ___ctrl_B___
|
||||
.byte $10 ; 3/03 ___ctrl_C___
|
||||
.byte $10 ; 4/04 ___ctrl_D___
|
||||
.byte $10 ; 5/05 ___ctrl_E___
|
||||
.byte $10 ; 6/06 ___ctrl_F___
|
||||
.byte $10 ; 7/07 ___ctrl_G___
|
||||
.byte $10 ; 8/08 ___ctrl_H___
|
||||
.byte $D0 ; 9/09 ___ctrl_I___
|
||||
.byte $50 ; 10/0a ___ctrl_J___
|
||||
.byte $50 ; 11/0b ___ctrl_K___
|
||||
.byte $50 ; 12/0c ___ctrl_L___
|
||||
.byte $50 ; 13/0d ___ctrl_M___
|
||||
.byte $10 ; 14/0e ___ctrl_N___
|
||||
.byte $10 ; 15/0f ___ctrl_O___
|
||||
.byte $10 ; 16/10 ___ctrl_P___
|
||||
.byte $10 ; 17/11 ___ctrl_Q___
|
||||
.byte $10 ; 18/12 ___ctrl_R___
|
||||
.byte $10 ; 19/13 ___ctrl_S___
|
||||
.byte $10 ; 20/14 ___ctrl_T___
|
||||
.byte $10 ; 21/15 ___ctrl_U___
|
||||
.byte $10 ; 22/16 ___ctrl_V___
|
||||
.byte $10 ; 23/17 ___ctrl_W___
|
||||
.byte $10 ; 24/18 ___ctrl_X___
|
||||
.byte $10 ; 25/19 ___ctrl_Y___
|
||||
.byte $10 ; 26/1a ___ctrl_Z___
|
||||
.byte $10 ; 27/1b ___ctrl_[___
|
||||
.byte $10 ; 28/1c ___ctrl_\___
|
||||
.byte $10 ; 29/1d ___ctrl_]___
|
||||
.byte $10 ; 30/1e ___ctrl_^___
|
||||
.byte $10 ; 31/1f ___ctrl_____
|
||||
.byte $A0 ; 32/20 ___SPACE___
|
||||
.byte $00 ; 33/21 _____!_____
|
||||
.byte $00 ; 34/22 _____"_____
|
||||
.byte $00 ; 35/23 _____#_____
|
||||
.byte $00 ; 36/24 _____$_____
|
||||
.byte $00 ; 37/25 _____%_____
|
||||
.byte $00 ; 38/26 _____&_____
|
||||
.byte $00 ; 39/27 _____'_____
|
||||
.byte $00 ; 40/28 _____(_____
|
||||
.byte $00 ; 41/29 _____)_____
|
||||
.byte $00 ; 42/2a _____*_____
|
||||
.byte $00 ; 43/2b _____+_____
|
||||
.byte $00 ; 44/2c _____,_____
|
||||
.byte $00 ; 45/2d _____-_____
|
||||
.byte $00 ; 46/2e _____._____
|
||||
.byte $00 ; 47/2f _____/_____
|
||||
.byte $0C ; 48/30 _____0_____
|
||||
.byte $0C ; 49/31 _____1_____
|
||||
.byte $0C ; 50/32 _____2_____
|
||||
.byte $0C ; 51/33 _____3_____
|
||||
.byte $0C ; 52/34 _____4_____
|
||||
.byte $0C ; 53/35 _____5_____
|
||||
.byte $0C ; 54/36 _____6_____
|
||||
.byte $0C ; 55/37 _____7_____
|
||||
.byte $0C ; 56/38 _____8_____
|
||||
.byte $0C ; 57/39 _____9_____
|
||||
.byte $00 ; 58/3a _____:_____
|
||||
.byte $00 ; 59/3b _____;_____
|
||||
.byte $00 ; 60/3c _____<_____
|
||||
.byte $00 ; 61/3d _____=_____
|
||||
.byte $00 ; 62/3e _____>_____
|
||||
.byte $00 ; 63/3f _____?_____
|
||||
.byte $10 ; 0/00 ___ctrl_@___
|
||||
.byte $10 ; 1/01 ___ctrl_A___
|
||||
.byte $10 ; 2/02 ___ctrl_B___
|
||||
.byte $10 ; 3/03 ___ctrl_C___
|
||||
.byte $10 ; 4/04 ___ctrl_D___
|
||||
.byte $10 ; 5/05 ___ctrl_E___
|
||||
.byte $10 ; 6/06 ___ctrl_F___
|
||||
.byte $10 ; 7/07 ___ctrl_G___
|
||||
.byte $10 ; 8/08 ___ctrl_H___
|
||||
.byte $D0 ; 9/09 ___ctrl_I___
|
||||
.byte $50 ; 10/0a ___ctrl_J___
|
||||
.byte $50 ; 11/0b ___ctrl_K___
|
||||
.byte $50 ; 12/0c ___ctrl_L___
|
||||
.byte $50 ; 13/0d ___ctrl_M___
|
||||
.byte $10 ; 14/0e ___ctrl_N___
|
||||
.byte $10 ; 15/0f ___ctrl_O___
|
||||
.byte $10 ; 16/10 ___ctrl_P___
|
||||
.byte $10 ; 17/11 ___ctrl_Q___
|
||||
.byte $10 ; 18/12 ___ctrl_R___
|
||||
.byte $10 ; 19/13 ___ctrl_S___
|
||||
.byte $10 ; 20/14 ___ctrl_T___
|
||||
.byte $10 ; 21/15 ___ctrl_U___
|
||||
.byte $10 ; 22/16 ___ctrl_V___
|
||||
.byte $10 ; 23/17 ___ctrl_W___
|
||||
.byte $10 ; 24/18 ___ctrl_X___
|
||||
.byte $10 ; 25/19 ___ctrl_Y___
|
||||
.byte $10 ; 26/1a ___ctrl_Z___
|
||||
.byte $10 ; 27/1b ___ctrl_[___
|
||||
.byte $10 ; 28/1c ___ctrl_\___
|
||||
.byte $10 ; 29/1d ___ctrl_]___
|
||||
.byte $10 ; 30/1e ___ctrl_^___
|
||||
.byte $10 ; 31/1f ___ctrl_____
|
||||
.byte $A0 ; 32/20 ___SPACE___
|
||||
.byte $00 ; 33/21 _____!_____
|
||||
.byte $00 ; 34/22 _____"_____
|
||||
.byte $00 ; 35/23 _____#_____
|
||||
.byte $00 ; 36/24 _____$_____
|
||||
.byte $00 ; 37/25 _____%_____
|
||||
.byte $00 ; 38/26 _____&_____
|
||||
.byte $00 ; 39/27 _____'_____
|
||||
.byte $00 ; 40/28 _____(_____
|
||||
.byte $00 ; 41/29 _____)_____
|
||||
.byte $00 ; 42/2a _____*_____
|
||||
.byte $00 ; 43/2b _____+_____
|
||||
.byte $00 ; 44/2c _____,_____
|
||||
.byte $00 ; 45/2d _____-_____
|
||||
.byte $00 ; 46/2e _____._____
|
||||
.byte $00 ; 47/2f _____/_____
|
||||
.byte $0C ; 48/30 _____0_____
|
||||
.byte $0C ; 49/31 _____1_____
|
||||
.byte $0C ; 50/32 _____2_____
|
||||
.byte $0C ; 51/33 _____3_____
|
||||
.byte $0C ; 52/34 _____4_____
|
||||
.byte $0C ; 53/35 _____5_____
|
||||
.byte $0C ; 54/36 _____6_____
|
||||
.byte $0C ; 55/37 _____7_____
|
||||
.byte $0C ; 56/38 _____8_____
|
||||
.byte $0C ; 57/39 _____9_____
|
||||
.byte $00 ; 58/3a _____:_____
|
||||
.byte $00 ; 59/3b _____;_____
|
||||
.byte $00 ; 60/3c _____<_____
|
||||
.byte $00 ; 61/3d _____=_____
|
||||
.byte $00 ; 62/3e _____>_____
|
||||
.byte $00 ; 63/3f _____?_____
|
||||
|
||||
.byte $00 ; 64/40 _____@_____
|
||||
.byte $0A ; 65/41 _____A_____
|
||||
.byte $0A ; 66/42 _____B_____
|
||||
.byte $0A ; 67/43 _____C_____
|
||||
.byte $0A ; 68/44 _____D_____
|
||||
.byte $0A ; 69/45 _____E_____
|
||||
.byte $0A ; 70/46 _____F_____
|
||||
.byte $02 ; 71/47 _____G_____
|
||||
.byte $02 ; 72/48 _____H_____
|
||||
.byte $02 ; 73/49 _____I_____
|
||||
.byte $02 ; 74/4a _____J_____
|
||||
.byte $02 ; 75/4b _____K_____
|
||||
.byte $02 ; 76/4c _____L_____
|
||||
.byte $02 ; 77/4d _____M_____
|
||||
.byte $02 ; 78/4e _____N_____
|
||||
.byte $02 ; 79/4f _____O_____
|
||||
.byte $02 ; 80/50 _____P_____
|
||||
.byte $02 ; 81/51 _____Q_____
|
||||
.byte $02 ; 82/52 _____R_____
|
||||
.byte $02 ; 83/53 _____S_____
|
||||
.byte $02 ; 84/54 _____T_____
|
||||
.byte $02 ; 85/55 _____U_____
|
||||
.byte $02 ; 86/56 _____V_____
|
||||
.byte $02 ; 87/57 _____W_____
|
||||
.byte $02 ; 88/58 _____X_____
|
||||
.byte $02 ; 89/59 _____Y_____
|
||||
.byte $02 ; 90/5a _____Z_____
|
||||
.byte $00 ; 91/5b _____[_____
|
||||
.byte $00 ; 92/5c _____\_____
|
||||
.byte $00 ; 93/5d _____]_____
|
||||
.byte $00 ; 94/5e _____^_____
|
||||
.byte $00 ; 95/5f _UNDERLINE_
|
||||
.byte $00 ; 96/60 ___grave___
|
||||
.byte $09 ; 97/61 _____a_____
|
||||
.byte $09 ; 98/62 _____b_____
|
||||
.byte $09 ; 99/63 _____c_____
|
||||
.byte $09 ; 100/64 _____d_____
|
||||
.byte $09 ; 101/65 _____e_____
|
||||
.byte $09 ; 102/66 _____f_____
|
||||
.byte $01 ; 103/67 _____g_____
|
||||
.byte $01 ; 104/68 _____h_____
|
||||
.byte $01 ; 105/69 _____i_____
|
||||
.byte $01 ; 106/6a _____j_____
|
||||
.byte $01 ; 107/6b _____k_____
|
||||
.byte $01 ; 108/6c _____l_____
|
||||
.byte $01 ; 109/6d _____m_____
|
||||
.byte $01 ; 110/6e _____n_____
|
||||
.byte $01 ; 111/6f _____o_____
|
||||
.byte $01 ; 112/70 _____p_____
|
||||
.byte $01 ; 113/71 _____q_____
|
||||
.byte $01 ; 114/72 _____r_____
|
||||
.byte $01 ; 115/73 _____s_____
|
||||
.byte $01 ; 116/74 _____t_____
|
||||
.byte $01 ; 117/75 _____u_____
|
||||
.byte $01 ; 118/76 _____v_____
|
||||
.byte $01 ; 119/77 _____w_____
|
||||
.byte $01 ; 120/78 _____x_____
|
||||
.byte $01 ; 121/79 _____y_____
|
||||
.byte $01 ; 122/7a _____z_____
|
||||
.byte $00 ; 123/7b _____{_____
|
||||
.byte $00 ; 124/7c _____|_____
|
||||
.byte $00 ; 125/7d _____}_____
|
||||
.byte $00 ; 126/7e _____~_____
|
||||
.byte $40 ; 127/7f ____DEL____
|
||||
.byte $00 ; 64/40 _____@_____
|
||||
.byte $0A ; 65/41 _____A_____
|
||||
.byte $0A ; 66/42 _____B_____
|
||||
.byte $0A ; 67/43 _____C_____
|
||||
.byte $0A ; 68/44 _____D_____
|
||||
.byte $0A ; 69/45 _____E_____
|
||||
.byte $0A ; 70/46 _____F_____
|
||||
.byte $02 ; 71/47 _____G_____
|
||||
.byte $02 ; 72/48 _____H_____
|
||||
.byte $02 ; 73/49 _____I_____
|
||||
.byte $02 ; 74/4a _____J_____
|
||||
.byte $02 ; 75/4b _____K_____
|
||||
.byte $02 ; 76/4c _____L_____
|
||||
.byte $02 ; 77/4d _____M_____
|
||||
.byte $02 ; 78/4e _____N_____
|
||||
.byte $02 ; 79/4f _____O_____
|
||||
.byte $02 ; 80/50 _____P_____
|
||||
.byte $02 ; 81/51 _____Q_____
|
||||
.byte $02 ; 82/52 _____R_____
|
||||
.byte $02 ; 83/53 _____S_____
|
||||
.byte $02 ; 84/54 _____T_____
|
||||
.byte $02 ; 85/55 _____U_____
|
||||
.byte $02 ; 86/56 _____V_____
|
||||
.byte $02 ; 87/57 _____W_____
|
||||
.byte $02 ; 88/58 _____X_____
|
||||
.byte $02 ; 89/59 _____Y_____
|
||||
.byte $02 ; 90/5a _____Z_____
|
||||
.byte $00 ; 91/5b _____[_____
|
||||
.byte $00 ; 92/5c _____\_____
|
||||
.byte $00 ; 93/5d _____]_____
|
||||
.byte $00 ; 94/5e _____^_____
|
||||
.byte $00 ; 95/5f _UNDERLINE_
|
||||
.byte $00 ; 96/60 ___grave___
|
||||
.byte $09 ; 97/61 _____a_____
|
||||
.byte $09 ; 98/62 _____b_____
|
||||
.byte $09 ; 99/63 _____c_____
|
||||
.byte $09 ; 100/64 _____d_____
|
||||
.byte $09 ; 101/65 _____e_____
|
||||
.byte $09 ; 102/66 _____f_____
|
||||
.byte $01 ; 103/67 _____g_____
|
||||
.byte $01 ; 104/68 _____h_____
|
||||
.byte $01 ; 105/69 _____i_____
|
||||
.byte $01 ; 106/6a _____j_____
|
||||
.byte $01 ; 107/6b _____k_____
|
||||
.byte $01 ; 108/6c _____l_____
|
||||
.byte $01 ; 109/6d _____m_____
|
||||
.byte $01 ; 110/6e _____n_____
|
||||
.byte $01 ; 111/6f _____o_____
|
||||
.byte $01 ; 112/70 _____p_____
|
||||
.byte $01 ; 113/71 _____q_____
|
||||
.byte $01 ; 114/72 _____r_____
|
||||
.byte $01 ; 115/73 _____s_____
|
||||
.byte $01 ; 116/74 _____t_____
|
||||
.byte $01 ; 117/75 _____u_____
|
||||
.byte $01 ; 118/76 _____v_____
|
||||
.byte $01 ; 119/77 _____w_____
|
||||
.byte $01 ; 120/78 _____x_____
|
||||
.byte $01 ; 121/79 _____y_____
|
||||
.byte $01 ; 122/7a _____z_____
|
||||
.byte $00 ; 123/7b _____{_____
|
||||
.byte $00 ; 124/7c _____|_____
|
||||
.byte $00 ; 125/7d _____}_____
|
||||
.byte $00 ; 126/7e _____~_____
|
||||
.byte $40 ; 127/7f ____DEL____
|
||||
|
||||
.endrepeat
|
||||
|
||||
@@ -5,28 +5,28 @@
|
||||
; void cvline (unsigned char length);
|
||||
;
|
||||
|
||||
.export _cvlinexy, _cvline
|
||||
.import popa, _gotoxy, putchar, newline
|
||||
.importzp tmp1
|
||||
.export _cvlinexy, _cvline
|
||||
.import popa, _gotoxy, putchar, newline
|
||||
.importzp tmp1
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
_cvlinexy:
|
||||
pha ; Save the length
|
||||
jsr popa ; Get y
|
||||
jsr _gotoxy ; Call this one, will pop params
|
||||
pla ; Restore the length and run into _cvline
|
||||
pha ; Save the length
|
||||
jsr popa ; Get y
|
||||
jsr _gotoxy ; Call this one, will pop params
|
||||
pla ; Restore the length and run into _cvline
|
||||
|
||||
_cvline:
|
||||
cmp #0 ; Is the length zero?
|
||||
beq L9 ; Jump if done
|
||||
sta tmp1
|
||||
L1: lda #CH_VLINE ; Vertical bar
|
||||
jsr putchar ; Write, no cursor advance
|
||||
jsr newline ; Advance cursor to next line
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
cmp #0 ; Is the length zero?
|
||||
beq L9 ; Jump if done
|
||||
sta tmp1
|
||||
L1: lda #CH_VLINE ; Vertical bar
|
||||
jsr putchar ; Write, no cursor advance
|
||||
jsr newline ; Advance cursor to next line
|
||||
dec tmp1
|
||||
bne L1
|
||||
L9: rts
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,33 +5,33 @@
|
||||
; /* Return the video mode the machine is using */
|
||||
;
|
||||
|
||||
.include "nes.inc"
|
||||
.include "get_tv.inc"
|
||||
.importzp tmp1, tmp2
|
||||
.include "nes.inc"
|
||||
.include "get_tv.inc"
|
||||
.importzp tmp1, tmp2
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
; _get_tv
|
||||
|
||||
.proc _get_tv
|
||||
.proc _get_tv
|
||||
|
||||
lda #TV::NTSC ; assume NTSC
|
||||
tax ; clear
|
||||
sta tmp1
|
||||
sta tmp2
|
||||
ldy tickcount
|
||||
wait: cpy tickcount
|
||||
beq wait
|
||||
iny ; next tick
|
||||
loop: cpy tickcount
|
||||
bne over
|
||||
inc tmp1
|
||||
bne loop
|
||||
inc tmp2
|
||||
bne loop
|
||||
over: ldy tmp2
|
||||
cpy #9
|
||||
bcc nopal
|
||||
lda #TV::PAL ; choose PAL
|
||||
nopal: rts
|
||||
lda #TV::NTSC ; assume NTSC
|
||||
tax ; clear
|
||||
sta tmp1
|
||||
sta tmp2
|
||||
ldy tickcount
|
||||
wait: cpy tickcount
|
||||
beq wait
|
||||
iny ; next tick
|
||||
loop: cpy tickcount
|
||||
bne over
|
||||
inc tmp1
|
||||
bne loop
|
||||
inc tmp2
|
||||
bne loop
|
||||
over: ldy tmp2
|
||||
cpy #9
|
||||
bcc nopal
|
||||
lda #TV::PAL ; choose PAL
|
||||
nopal: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
; void gotox (unsigned char x);
|
||||
;
|
||||
|
||||
.export _gotox
|
||||
.import setcursor
|
||||
.export _gotox
|
||||
.import setcursor
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
.proc _gotox
|
||||
|
||||
sta CURS_X ; Set new position
|
||||
sta CURS_X ; Set new position
|
||||
tay
|
||||
ldx CURS_Y
|
||||
jmp setcursor ; Set the cursor to the new position
|
||||
jmp setcursor ; Set the cursor to the new position
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
; void gotoxy (unsigned char x, unsigned char y);
|
||||
;
|
||||
|
||||
.export _gotoxy
|
||||
.export _gotoxy
|
||||
.import setcursor
|
||||
.import popa
|
||||
.import popa
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
.proc _gotoxy
|
||||
|
||||
sta CURS_Y ; Set Y
|
||||
jsr popa ; Get X
|
||||
sta CURS_X ; Set X
|
||||
sta CURS_Y ; Set Y
|
||||
jsr popa ; Get X
|
||||
sta CURS_X ; Set X
|
||||
tay
|
||||
ldx CURS_Y
|
||||
jmp setcursor ; Set the cursor position
|
||||
jmp setcursor ; Set the cursor position
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
; void gotoy (unsigned char y);
|
||||
;
|
||||
|
||||
.export _gotoy
|
||||
.import setcursor
|
||||
.export _gotoy
|
||||
.import setcursor
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
.proc _gotoy
|
||||
|
||||
sta CURS_Y ; Set new position
|
||||
sta CURS_Y ; Set new position
|
||||
tax
|
||||
ldy CURS_X
|
||||
jmp setcursor ; Set the cursor to the new position
|
||||
jmp setcursor ; Set the cursor to the new position
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
; Stefan Haubenthal, 2004-10-05
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "nes.inc"
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "nes.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -20,32 +20,32 @@
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $10 ; JOY_UP
|
||||
.byte $20 ; JOY_DOWN
|
||||
.byte $40 ; JOY_LEFT
|
||||
.byte $80 ; JOY_RIGHT
|
||||
.byte $01 ; JOY_FIRE (A)
|
||||
.byte $02 ; JOY_FIRE2 (B)
|
||||
.byte $04 ; (Select)
|
||||
.byte $08 ; (Start)
|
||||
.byte $10 ; JOY_UP
|
||||
.byte $20 ; JOY_DOWN
|
||||
.byte $40 ; JOY_LEFT
|
||||
.byte $80 ; JOY_RIGHT
|
||||
.byte $01 ; JOY_FIRE (A)
|
||||
.byte $02 ; JOY_FIRE2 (B)
|
||||
.byte $04 ; (Select)
|
||||
.byte $08 ; (Start)
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READJOY
|
||||
.addr 0 ; IRQ entry unused
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READJOY
|
||||
.addr 0 ; IRQ entry unused
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
JOY_COUNT = 2 ; Number of joysticks we support
|
||||
JOY_COUNT = 2 ; Number of joysticks we support
|
||||
|
||||
|
||||
.code
|
||||
@@ -58,9 +58,9 @@ JOY_COUNT = 2 ; Number of joysticks we support
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
lda #JOY_ERR_OK
|
||||
ldx #0
|
||||
; rts ; Run into UNINSTALL instead
|
||||
lda #JOY_ERR_OK
|
||||
ldx #0
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -76,8 +76,8 @@ UNINSTALL:
|
||||
;
|
||||
|
||||
COUNT:
|
||||
lda #JOY_COUNT
|
||||
ldx #0
|
||||
lda #JOY_COUNT
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -85,23 +85,23 @@ COUNT:
|
||||
;
|
||||
|
||||
READJOY:
|
||||
and #$01 ; Fix joystick number
|
||||
tay ; Joystick number (0,1) into Y
|
||||
and #$01 ; Fix joystick number
|
||||
tay ; Joystick number (0,1) into Y
|
||||
|
||||
lda #1
|
||||
sta APU_PAD1,y
|
||||
lda #0
|
||||
sta APU_PAD1,y
|
||||
lda #1
|
||||
sta APU_PAD1,y
|
||||
lda #0
|
||||
sta APU_PAD1,y
|
||||
|
||||
; Read joystick
|
||||
|
||||
ldx #8
|
||||
@Loop: lda APU_PAD1,y
|
||||
ror a
|
||||
ror tmp1
|
||||
ldx #8
|
||||
@Loop: lda APU_PAD1,y
|
||||
ror a
|
||||
ror tmp1
|
||||
dex
|
||||
bne @Loop
|
||||
bne @Loop
|
||||
|
||||
lda tmp1
|
||||
; ldx #$00 ; X implicitly fixed
|
||||
lda tmp1
|
||||
; ldx #$00 ; X implicitly fixed
|
||||
rts
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const void joy_static_stddrv[];
|
||||
;
|
||||
|
||||
.export _joy_static_stddrv
|
||||
.import _nes_stdjoy_joy
|
||||
.export _joy_static_stddrv
|
||||
.import _nes_stdjoy_joy
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const char joy_stddrv[];
|
||||
;
|
||||
|
||||
.export _joy_stddrv
|
||||
.export _joy_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_joy_stddrv: .asciiz "nes-stdjoy.joy"
|
||||
_joy_stddrv: .asciiz "nes-stdjoy.joy"
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
;
|
||||
|
||||
|
||||
.constructor initmainargs, 24
|
||||
.import __argc, __argv
|
||||
.constructor initmainargs, 24
|
||||
.import __argc, __argv
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
218
libsrc/nes/ppu.s
218
libsrc/nes/ppu.s
@@ -3,130 +3,130 @@
|
||||
; Cleanup by Ullrich von Bassewitz <uz@cc65.org>
|
||||
;
|
||||
|
||||
.export ppuinit
|
||||
.export paletteinit, paldata
|
||||
.export ppuinit
|
||||
.export paletteinit, paldata
|
||||
|
||||
.include "nes.inc"
|
||||
.include "nes.inc"
|
||||
|
||||
;+---------+----------------------------------------------------------+
|
||||
;| $2000 | PPU Control Register #1 (W) |
|
||||
;| | |
|
||||
;| | D7: Execute NMI on VBlank |
|
||||
;| | 0 = Disabled |
|
||||
;| | 1 = Enabled |
|
||||
;| | D6: PPU Master/Slave Selection --+ |
|
||||
;| | 0 = Master +-- UNUSED |
|
||||
;| | 1 = Slave --+ |
|
||||
;| | D5: Sprite Size |
|
||||
;| | 0 = 8x8 |
|
||||
;| | 1 = 8x16 |
|
||||
;| | D4: Background Pattern Table Address |
|
||||
;| | 0 = $0000 (VRAM) |
|
||||
;| | 1 = $1000 (VRAM) |
|
||||
;| | D3: Sprite Pattern Table Address |
|
||||
;| | 0 = $0000 (VRAM) |
|
||||
;| | 1 = $1000 (VRAM) |
|
||||
;| | D2: PPU Address Increment |
|
||||
;| | 0 = Increment by 1 |
|
||||
;| | 1 = Increment by 32 |
|
||||
;| | D1-D0: Name Table Address |
|
||||
;| | 00 = $2000 (VRAM) |
|
||||
;| | 01 = $2400 (VRAM) |
|
||||
;| | 10 = $2800 (VRAM) |
|
||||
;| | 11 = $2C00 (VRAM) |
|
||||
;| $2000 | PPU Control Register #1 (W) |
|
||||
;| | |
|
||||
;| | D7: Execute NMI on VBlank |
|
||||
;| | 0 = Disabled |
|
||||
;| | 1 = Enabled |
|
||||
;| | D6: PPU Master/Slave Selection --+ |
|
||||
;| | 0 = Master +-- UNUSED |
|
||||
;| | 1 = Slave --+ |
|
||||
;| | D5: Sprite Size |
|
||||
;| | 0 = 8x8 |
|
||||
;| | 1 = 8x16 |
|
||||
;| | D4: Background Pattern Table Address |
|
||||
;| | 0 = $0000 (VRAM) |
|
||||
;| | 1 = $1000 (VRAM) |
|
||||
;| | D3: Sprite Pattern Table Address |
|
||||
;| | 0 = $0000 (VRAM) |
|
||||
;| | 1 = $1000 (VRAM) |
|
||||
;| | D2: PPU Address Increment |
|
||||
;| | 0 = Increment by 1 |
|
||||
;| | 1 = Increment by 32 |
|
||||
;| | D1-D0: Name Table Address |
|
||||
;| | 00 = $2000 (VRAM) |
|
||||
;| | 01 = $2400 (VRAM) |
|
||||
;| | 10 = $2800 (VRAM) |
|
||||
;| | 11 = $2C00 (VRAM) |
|
||||
;+---------+----------------------------------------------------------+
|
||||
;+---------+----------------------------------------------------------+
|
||||
;| $2001 | PPU Control Register #2 (W) |
|
||||
;| | |
|
||||
;| | D7-D5: Full Background Colour (when D0 == 1) |
|
||||
;| | 000 = None +------------+ |
|
||||
;| | 001 = Green | NOTE: Do not use more |
|
||||
;| | 010 = Blue | than one type |
|
||||
;| | 100 = Red +------------+ |
|
||||
;| | D7-D5: Colour Intensity (when D0 == 0) |
|
||||
;| | 000 = None +--+ |
|
||||
;| | 001 = Intensify green | NOTE: Do not use more |
|
||||
;| | 010 = Intensify blue | than one type |
|
||||
;| | 100 = Intensify red +--+ |
|
||||
;| | D4: Sprite Visibility |
|
||||
;| | 0 = Sprites not displayed |
|
||||
;| | 1 = Sprites visible |
|
||||
;| | D3: Background Visibility |
|
||||
;| | 0 = Background not displayed |
|
||||
;| | 1 = Background visible |
|
||||
;| | D2: Sprite Clipping |
|
||||
;| | 0 = Sprites invisible in left 8-pixel column |
|
||||
;| | 1 = No clipping |
|
||||
;| | D1: Background Clipping |
|
||||
;| | 0 = BG invisible in left 8-pixel column |
|
||||
;| | 1 = No clipping |
|
||||
;| | D0: Display Type |
|
||||
;| | 0 = Colour display |
|
||||
;| | 1 = Monochrome display |
|
||||
;| $2001 | PPU Control Register #2 (W) |
|
||||
;| | |
|
||||
;| | D7-D5: Full Background Colour (when D0 == 1) |
|
||||
;| | 000 = None +------------+ |
|
||||
;| | 001 = Green | NOTE: Do not use more |
|
||||
;| | 010 = Blue | than one type |
|
||||
;| | 100 = Red +------------+ |
|
||||
;| | D7-D5: Colour Intensity (when D0 == 0) |
|
||||
;| | 000 = None +--+ |
|
||||
;| | 001 = Intensify green | NOTE: Do not use more |
|
||||
;| | 010 = Intensify blue | than one type |
|
||||
;| | 100 = Intensify red +--+ |
|
||||
;| | D4: Sprite Visibility |
|
||||
;| | 0 = Sprites not displayed |
|
||||
;| | 1 = Sprites visible |
|
||||
;| | D3: Background Visibility |
|
||||
;| | 0 = Background not displayed |
|
||||
;| | 1 = Background visible |
|
||||
;| | D2: Sprite Clipping |
|
||||
;| | 0 = Sprites invisible in left 8-pixel column |
|
||||
;| | 1 = No clipping |
|
||||
;| | D1: Background Clipping |
|
||||
;| | 0 = BG invisible in left 8-pixel column |
|
||||
;| | 1 = No clipping |
|
||||
;| | D0: Display Type |
|
||||
;| | 0 = Colour display |
|
||||
;| | 1 = Monochrome display |
|
||||
;+---------+----------------------------------------------------------+
|
||||
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
.proc ppuinit
|
||||
.proc ppuinit
|
||||
|
||||
lda #%10101000
|
||||
sta PPU_CTRL1
|
||||
lda #%10101000
|
||||
sta PPU_CTRL1
|
||||
|
||||
lda #%00011110
|
||||
sta PPU_CTRL2
|
||||
lda #%00011110
|
||||
sta PPU_CTRL2
|
||||
|
||||
; Wait for vblank
|
||||
|
||||
@wait: lda PPU_STATUS
|
||||
bpl @wait
|
||||
@wait: lda PPU_STATUS
|
||||
bpl @wait
|
||||
|
||||
; reset scrolling
|
||||
|
||||
lda #0
|
||||
sta PPU_VRAM_ADDR1
|
||||
sta PPU_VRAM_ADDR1
|
||||
lda #0
|
||||
sta PPU_VRAM_ADDR1
|
||||
sta PPU_VRAM_ADDR1
|
||||
|
||||
; Make all sprites invisible
|
||||
|
||||
lda #$00
|
||||
ldy #$f0
|
||||
sta PPU_SPR_ADDR
|
||||
ldx #$40
|
||||
@loop: sty PPU_SPR_IO
|
||||
sta PPU_SPR_IO
|
||||
sta PPU_SPR_IO
|
||||
sty PPU_SPR_IO
|
||||
dex
|
||||
bne @loop
|
||||
lda #$00
|
||||
ldy #$f0
|
||||
sta PPU_SPR_ADDR
|
||||
ldx #$40
|
||||
@loop: sty PPU_SPR_IO
|
||||
sta PPU_SPR_IO
|
||||
sta PPU_SPR_IO
|
||||
sty PPU_SPR_IO
|
||||
dex
|
||||
bne @loop
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
.proc paletteinit
|
||||
.proc paletteinit
|
||||
|
||||
; Wait for v-blank
|
||||
@wait: lda PPU_STATUS
|
||||
bpl @wait
|
||||
@wait: lda PPU_STATUS
|
||||
bpl @wait
|
||||
|
||||
lda #$3F
|
||||
sta PPU_VRAM_ADDR2
|
||||
lda #$00
|
||||
sta PPU_VRAM_ADDR2
|
||||
lda #$3F
|
||||
sta PPU_VRAM_ADDR2
|
||||
lda #$00
|
||||
sta PPU_VRAM_ADDR2
|
||||
|
||||
ldx #0
|
||||
@loop: lda paldata,x
|
||||
sta PPU_VRAM_IO
|
||||
inx
|
||||
cpx #(16*2)
|
||||
bne @loop
|
||||
ldx #0
|
||||
@loop: lda paldata,x
|
||||
sta PPU_VRAM_IO
|
||||
inx
|
||||
cpx #(16*2)
|
||||
bne @loop
|
||||
|
||||
rts
|
||||
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
@@ -134,24 +134,24 @@
|
||||
.rodata
|
||||
|
||||
paldata:
|
||||
.repeat 2
|
||||
.byte $0f ; 0 black
|
||||
.byte $14 ; 4 violett
|
||||
.byte $3b ; 3 cyan
|
||||
.byte $3d ; 1 white
|
||||
.repeat 2
|
||||
.byte $0f ; 0 black
|
||||
.byte $14 ; 4 violett
|
||||
.byte $3b ; 3 cyan
|
||||
.byte $3d ; 1 white
|
||||
|
||||
.byte $38 ; 7 yellow
|
||||
.byte $2d ; b dark grey
|
||||
.byte $22 ; e light blue
|
||||
.byte $04 ; 2 red
|
||||
.byte $38 ; 7 yellow
|
||||
.byte $2d ; b dark grey
|
||||
.byte $22 ; e light blue
|
||||
.byte $04 ; 2 red
|
||||
|
||||
.byte $18 ; 8 orange
|
||||
.byte $08 ; 9 brown
|
||||
.byte $35 ; a light red
|
||||
.byte $01 ; 6 blue
|
||||
.byte $18 ; 8 orange
|
||||
.byte $08 ; 9 brown
|
||||
.byte $35 ; a light red
|
||||
.byte $01 ; 6 blue
|
||||
|
||||
.byte $10 ; c middle grey
|
||||
.byte $2b ; d light green
|
||||
.byte $3d ; f light gray
|
||||
.byte $1a ; 5 green
|
||||
.endrepeat
|
||||
.byte $10 ; c middle grey
|
||||
.byte $2b ; d light green
|
||||
.byte $3d ; f light gray
|
||||
.byte $1a ; 5 green
|
||||
.endrepeat
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
|
||||
@wait: lda ringcount
|
||||
bne @wait
|
||||
rts
|
||||
bne @wait
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
|
||||
lda #$ff ; (($0100/3)*1)
|
||||
@wait: cmp ringcount
|
||||
beq @wait
|
||||
rts
|
||||
beq @wait
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
; /* Initialize the random number generator */
|
||||
;
|
||||
|
||||
.export __randomize
|
||||
.import _srand
|
||||
.export __randomize
|
||||
.import _srand
|
||||
|
||||
.include "nes.inc"
|
||||
.include "nes.inc"
|
||||
|
||||
__randomize:
|
||||
ldx tickcount ; Use tick clock
|
||||
|
||||
@@ -4,24 +4,24 @@
|
||||
; unsigned char revers (unsigned char onoff);
|
||||
;
|
||||
|
||||
.export _revers
|
||||
.export _revers
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
.proc _revers
|
||||
|
||||
ldx #$00 ; Assume revers off
|
||||
tay ; Test onoff
|
||||
beq L1 ; Jump if off
|
||||
ldx #$80 ; Load on value
|
||||
ldy #$00 ; Assume old value is zero
|
||||
L1: lda RVS ; Load old value
|
||||
stx RVS ; Set new value
|
||||
beq L2 ; Jump if old value zero
|
||||
iny ; Make old value = 1
|
||||
L2: ldx #$00 ; Load high byte of result
|
||||
tya ; Load low byte, set CC
|
||||
rts
|
||||
ldx #$00 ; Assume revers off
|
||||
tay ; Test onoff
|
||||
beq L1 ; Jump if off
|
||||
ldx #$80 ; Load on value
|
||||
ldy #$00 ; Assume old value is zero
|
||||
L1: lda RVS ; Load old value
|
||||
stx RVS ; Set new value
|
||||
beq L2 ; Jump if old value zero
|
||||
iny ; Make old value = 1
|
||||
L2: ldx #$00 ; Load high byte of result
|
||||
tya ; Load low byte, set CC
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
;
|
||||
; Set the cursor position
|
||||
|
||||
.export setcursor
|
||||
.export setcursor
|
||||
|
||||
.include "nes.inc"
|
||||
.include "nes.inc"
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
.proc setcursor
|
||||
|
||||
tya
|
||||
clc
|
||||
adc addrlo,x
|
||||
sta SCREEN_PTR
|
||||
tya
|
||||
clc
|
||||
adc addrlo,x
|
||||
sta SCREEN_PTR
|
||||
|
||||
lda addrhi,x
|
||||
adc #0
|
||||
sta SCREEN_PTR+1
|
||||
lda addrhi,x
|
||||
adc #0
|
||||
sta SCREEN_PTR+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
@@ -28,10 +28,10 @@
|
||||
; Tables with screen addresses
|
||||
|
||||
addrlo: .repeat screenrows,line
|
||||
.byte <($2000+((1*32))+(line*charsperline))
|
||||
.endrepeat
|
||||
.byte <($2000+((1*32))+(line*charsperline))
|
||||
.endrepeat
|
||||
|
||||
addrhi: .repeat screenrows,line
|
||||
.byte >($2000+((1*32))+(line*charsperline))
|
||||
.endrepeat
|
||||
.byte >($2000+((1*32))+(line*charsperline))
|
||||
.endrepeat
|
||||
|
||||
|
||||
@@ -5,59 +5,59 @@
|
||||
; Based on Maciej Witkowiak's line routine.
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-error.inc"
|
||||
.include "nes.inc"
|
||||
.include "get_tv.inc"
|
||||
.import _clrscr, setcursor, putchar
|
||||
.import paldata
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-error.inc"
|
||||
.include "nes.inc"
|
||||
.include "get_tv.inc"
|
||||
.import _clrscr, setcursor, putchar
|
||||
.import paldata
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table and constants.
|
||||
|
||||
.segment "JUMPTABLE"
|
||||
.segment "JUMPTABLE"
|
||||
|
||||
; First part of the header is a structure that has a magic and defines the
|
||||
; capabilities of the driver
|
||||
|
||||
.byte $74, $67, $69 ; "tgi"
|
||||
.byte TGI_API_VERSION ; TGI API version number
|
||||
xres: .word charsperline*2 ; Max X resolution
|
||||
yres: .word 56 ; Max Y resolution
|
||||
.byte 2 ; Number of drawing colors
|
||||
.byte 1 ; Number of screens available
|
||||
.byte 2 ; System font X size
|
||||
.byte 2 ; System font Y size
|
||||
.word $100 ; Aspect ratio
|
||||
.byte 0 ; TGI driver flags
|
||||
.byte $74, $67, $69 ; "tgi"
|
||||
.byte TGI_API_VERSION ; TGI API version number
|
||||
xres: .word charsperline*2 ; Max X resolution
|
||||
yres: .word 56 ; Max Y resolution
|
||||
.byte 2 ; Number of drawing colors
|
||||
.byte 1 ; Number of screens available
|
||||
.byte 2 ; System font X size
|
||||
.byte 2 ; System font Y size
|
||||
.word $100 ; Aspect ratio
|
||||
.byte 0 ; TGI driver flags
|
||||
|
||||
; Next comes the jump table. Currently all entries must be valid and may point
|
||||
; to an RTS for test versions (function not implemented).
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr INIT
|
||||
.addr DONE
|
||||
.addr GETERROR
|
||||
.addr CONTROL
|
||||
.addr CLEAR
|
||||
.addr SETVIEWPAGE
|
||||
.addr SETDRAWPAGE
|
||||
.addr SETCOLOR
|
||||
.addr SETPALETTE
|
||||
.addr GETPALETTE
|
||||
.addr GETDEFPALETTE
|
||||
.addr SETPIXEL
|
||||
.addr GETPIXEL
|
||||
.addr LINE
|
||||
.addr BAR
|
||||
.addr TEXTSTYLE
|
||||
.addr OUTTEXT
|
||||
.addr 0 ; IRQ entry is unused
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr INIT
|
||||
.addr DONE
|
||||
.addr GETERROR
|
||||
.addr CONTROL
|
||||
.addr CLEAR
|
||||
.addr SETVIEWPAGE
|
||||
.addr SETDRAWPAGE
|
||||
.addr SETCOLOR
|
||||
.addr SETPALETTE
|
||||
.addr GETPALETTE
|
||||
.addr GETDEFPALETTE
|
||||
.addr SETPIXEL
|
||||
.addr GETPIXEL
|
||||
.addr LINE
|
||||
.addr BAR
|
||||
.addr TEXTSTYLE
|
||||
.addr OUTTEXT
|
||||
.addr 0 ; IRQ entry is unused
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
@@ -65,57 +65,57 @@ yres: .word 56 ; Max Y resolution
|
||||
; Variables mapped to the zero page segment variables. Some of these are
|
||||
; used for passing parameters to the driver.
|
||||
|
||||
X1 = ptr1
|
||||
Y1 = ptr2
|
||||
X2 = ptr3
|
||||
Y2 = ptr4
|
||||
RADIUS = tmp1
|
||||
X1 = ptr1
|
||||
Y1 = ptr2
|
||||
X2 = ptr3
|
||||
Y2 = ptr4
|
||||
RADIUS = tmp1
|
||||
|
||||
ADDR = tmp1
|
||||
TEMP = tmp3
|
||||
TEMP2 = tmp4
|
||||
TEMP3 = sreg
|
||||
TEMP4 = sreg+1
|
||||
ADDR = tmp1
|
||||
TEMP = tmp3
|
||||
TEMP2 = tmp4
|
||||
TEMP3 = sreg
|
||||
TEMP4 = sreg+1
|
||||
|
||||
; Line routine stuff (must be on zpage)
|
||||
PB = ptr3 ; (2) LINE
|
||||
UB = ptr4 ; (2) LINE
|
||||
ERR = regsave ; (2) LINE
|
||||
NX = regsave+2 ; (2) LINE
|
||||
PB = ptr3 ; (2) LINE
|
||||
UB = ptr4 ; (2) LINE
|
||||
ERR = regsave ; (2) LINE
|
||||
NX = regsave+2 ; (2) LINE
|
||||
|
||||
; Absolute variables used in the code
|
||||
|
||||
.bss
|
||||
|
||||
MEM: .res charsperline*2*56/4
|
||||
MEM: .res charsperline*2*56/4
|
||||
MEMEND:
|
||||
ERROR: .res 1 ; Error code
|
||||
COLOR: .res 1 ; Current color
|
||||
PALETTE: .res 2 ; The current palette
|
||||
ERROR: .res 1 ; Error code
|
||||
COLOR: .res 1 ; Current color
|
||||
PALETTE: .res 2 ; The current palette
|
||||
|
||||
; Line routine stuff
|
||||
|
||||
OGora:
|
||||
COUNT: .res 2
|
||||
COUNT: .res 2
|
||||
OUkos:
|
||||
NY: .res 2
|
||||
NY: .res 2
|
||||
Y3:
|
||||
DX: .res 1
|
||||
DY: .res 1
|
||||
AY: .res 1
|
||||
DX: .res 1
|
||||
DY: .res 1
|
||||
AY: .res 1
|
||||
|
||||
; Constants and tables
|
||||
|
||||
.rodata
|
||||
|
||||
DEFPALETTE: .byte $0, $1
|
||||
OFFSET: .byte 8, 4, 2, 1
|
||||
; 00 00 00 00 01 01 01 01
|
||||
; 00 01 10 11 00 01 10 11
|
||||
CODE: .byte 32, 29, 26, 25, 28, 24+128, 31+128, 30+128
|
||||
; 10 10 10 10 11 11 11 11
|
||||
; 00 01 10 11 00 01 10 11
|
||||
.byte 30, 31, 24, 28+128, 25+128, 26+128, 29+128, 32+128
|
||||
DEFPALETTE: .byte $0, $1
|
||||
OFFSET: .byte 8, 4, 2, 1
|
||||
; 00 00 00 00 01 01 01 01
|
||||
; 00 01 10 11 00 01 10 11
|
||||
CODE: .byte 32, 29, 26, 25, 28, 24+128, 31+128, 30+128
|
||||
; 10 10 10 10 11 11 11 11
|
||||
; 00 01 10 11 00 01 10 11
|
||||
.byte 30, 31, 24, 28+128, 25+128, 26+128, 29+128, 32+128
|
||||
|
||||
.code
|
||||
|
||||
@@ -128,13 +128,13 @@ CODE: .byte 32, 29, 26, 25, 28, 24+128, 31+128, 30+128
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
jsr _get_tv
|
||||
cmp #TV::NTSC
|
||||
beq ntsc
|
||||
jsr _get_tv
|
||||
cmp #TV::NTSC
|
||||
beq ntsc
|
||||
; TODO ROM!
|
||||
inc yres
|
||||
inc yres
|
||||
ntsc:; rts
|
||||
inc yres
|
||||
inc yres
|
||||
ntsc:; rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory. May
|
||||
@@ -144,7 +144,7 @@ ntsc:; rts
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; INIT: Changes an already installed device from text mode to graphics
|
||||
@@ -164,9 +164,9 @@ INIT:
|
||||
|
||||
; Done, reset the error code
|
||||
|
||||
lda #TGI_ERR_OK
|
||||
sta ERROR
|
||||
; rts
|
||||
lda #TGI_ERR_OK
|
||||
sta ERROR
|
||||
; rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; DONE: Will be called to switch the graphics device back into text mode.
|
||||
@@ -177,16 +177,16 @@ INIT:
|
||||
;
|
||||
|
||||
DONE:
|
||||
rts
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; GETERROR: Return the error code in A and clear it.
|
||||
|
||||
GETERROR:
|
||||
lda ERROR
|
||||
ldx #TGI_ERR_OK
|
||||
stx ERROR
|
||||
rts
|
||||
lda ERROR
|
||||
ldx #TGI_ERR_OK
|
||||
stx ERROR
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; CONTROL: Platform/driver specific entry point.
|
||||
@@ -195,9 +195,9 @@ GETERROR:
|
||||
;
|
||||
|
||||
CONTROL:
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
rts
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; CLEAR: Clears the screen.
|
||||
@@ -206,20 +206,20 @@ CONTROL:
|
||||
;
|
||||
|
||||
CLEAR:
|
||||
ldx #<MEM
|
||||
stx TEMP
|
||||
ldx #>MEM
|
||||
stx TEMP+1
|
||||
lda #0
|
||||
tay
|
||||
@L1: sta (TEMP),y
|
||||
iny
|
||||
bne @L1
|
||||
inc TEMP+1
|
||||
inx
|
||||
cpx #>MEMEND
|
||||
bne @L1
|
||||
jmp _clrscr
|
||||
ldx #<MEM
|
||||
stx TEMP
|
||||
ldx #>MEM
|
||||
stx TEMP+1
|
||||
lda #0
|
||||
tay
|
||||
@L1: sta (TEMP),y
|
||||
iny
|
||||
bne @L1
|
||||
inc TEMP+1
|
||||
inx
|
||||
cpx #>MEMEND
|
||||
bne @L1
|
||||
jmp _clrscr
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETCOLOR: Set the drawing color (in A). The new color is already checked
|
||||
@@ -229,8 +229,8 @@ CLEAR:
|
||||
;
|
||||
|
||||
SETCOLOR:
|
||||
sta COLOR
|
||||
; rts
|
||||
sta COLOR
|
||||
; rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
|
||||
@@ -249,7 +249,7 @@ SETVIEWPAGE:
|
||||
;
|
||||
|
||||
SETDRAWPAGE:
|
||||
rts
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETPALETTE: Set the palette (not available with all drivers/hardware).
|
||||
@@ -261,31 +261,31 @@ SETDRAWPAGE:
|
||||
|
||||
SETPALETTE:
|
||||
; Wait for v-blank
|
||||
@wait: lda PPU_STATUS
|
||||
bpl @wait
|
||||
@wait: lda PPU_STATUS
|
||||
bpl @wait
|
||||
|
||||
lda #$3F
|
||||
sta PPU_VRAM_ADDR2
|
||||
lda #$00
|
||||
sta PPU_VRAM_ADDR2
|
||||
lda #$3F
|
||||
sta PPU_VRAM_ADDR2
|
||||
lda #$00
|
||||
sta PPU_VRAM_ADDR2
|
||||
|
||||
ldy #0
|
||||
lda (ptr1),y
|
||||
sta PALETTE
|
||||
tax
|
||||
lda paldata,x
|
||||
; sta PPU_VRAM_IO
|
||||
ldy #0
|
||||
lda (ptr1),y
|
||||
sta PALETTE
|
||||
tax
|
||||
lda paldata,x
|
||||
; sta PPU_VRAM_IO
|
||||
|
||||
iny
|
||||
lda (ptr1),y
|
||||
sta PALETTE+1
|
||||
tax
|
||||
lda paldata,x
|
||||
sta PPU_VRAM_IO
|
||||
iny
|
||||
lda (ptr1),y
|
||||
sta PALETTE+1
|
||||
tax
|
||||
lda paldata,x
|
||||
sta PPU_VRAM_IO
|
||||
|
||||
lda #TGI_ERR_OK
|
||||
sta ERROR
|
||||
rts
|
||||
lda #TGI_ERR_OK
|
||||
sta ERROR
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
|
||||
@@ -296,9 +296,9 @@ SETPALETTE:
|
||||
;
|
||||
|
||||
GETPALETTE:
|
||||
lda #<PALETTE
|
||||
ldx #>PALETTE
|
||||
rts
|
||||
lda #<PALETTE
|
||||
ldx #>PALETTE
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; GETDEFPALETTE: Return the default palette for the driver in A/X. All
|
||||
@@ -310,9 +310,9 @@ GETPALETTE:
|
||||
;
|
||||
|
||||
GETDEFPALETTE:
|
||||
lda #<DEFPALETTE
|
||||
ldx #>DEFPALETTE
|
||||
rts
|
||||
lda #<DEFPALETTE
|
||||
ldx #>DEFPALETTE
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
|
||||
@@ -323,41 +323,41 @@ GETDEFPALETTE:
|
||||
;
|
||||
|
||||
SETPIXEL:
|
||||
ldx Y1 ; y+2<yres
|
||||
inx
|
||||
inx
|
||||
cpx yres
|
||||
bcc @L2
|
||||
ldx X1 ; x+2<xres
|
||||
inx
|
||||
inx
|
||||
cpx xres
|
||||
bcc @L2
|
||||
rts
|
||||
@L2: lda X1
|
||||
lsr
|
||||
tay
|
||||
lda Y1
|
||||
lsr
|
||||
tax
|
||||
clc
|
||||
jsr setcursor
|
||||
jsr CALC
|
||||
ldx COLOR
|
||||
bne @set2
|
||||
eor #%00001111
|
||||
@set2: sta TEMP3
|
||||
ldx Y1 ; y+2<yres
|
||||
inx
|
||||
inx
|
||||
cpx yres
|
||||
bcc @L2
|
||||
ldx X1 ; x+2<xres
|
||||
inx
|
||||
inx
|
||||
cpx xres
|
||||
bcc @L2
|
||||
rts
|
||||
@L2: lda X1
|
||||
lsr
|
||||
tay
|
||||
lda Y1
|
||||
lsr
|
||||
tax
|
||||
clc
|
||||
jsr setcursor
|
||||
jsr CALC
|
||||
ldx COLOR
|
||||
bne @set2
|
||||
eor #%00001111
|
||||
@set2: sta TEMP3
|
||||
|
||||
lda (TEMP),y
|
||||
ldx COLOR
|
||||
bne @set
|
||||
and TEMP3
|
||||
.byte $2c
|
||||
@set: ora TEMP3
|
||||
sta (TEMP),y
|
||||
tax
|
||||
lda CODE,x
|
||||
@normal:jmp putchar
|
||||
lda (TEMP),y
|
||||
ldx COLOR
|
||||
bne @set
|
||||
and TEMP3
|
||||
.byte $2c
|
||||
@set: ora TEMP3
|
||||
sta (TEMP),y
|
||||
tax
|
||||
lda CODE,x
|
||||
@normal:jmp putchar
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; GETPIXEL: Read the color value of a pixel and return it in A/X. The
|
||||
@@ -366,14 +366,14 @@ SETPIXEL:
|
||||
|
||||
|
||||
GETPIXEL:
|
||||
jsr CALC
|
||||
sta TEMP3
|
||||
lda (TEMP),y
|
||||
and TEMP3
|
||||
beq @L1
|
||||
lda #1
|
||||
@L1: ldx #0
|
||||
rts
|
||||
jsr CALC
|
||||
sta TEMP3
|
||||
lda (TEMP),y
|
||||
and TEMP3
|
||||
beq @L1
|
||||
lda #1
|
||||
@L1: ldx #0
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
|
||||
@@ -381,32 +381,32 @@ GETPIXEL:
|
||||
; Contrary to most other functions, the graphics kernel will sort and clip
|
||||
; the coordinates before calling the driver, so on entry the following
|
||||
; conditions are valid:
|
||||
; X1 <= X2
|
||||
; Y1 <= Y2
|
||||
; (X1 >= 0) && (X1 < XRES)
|
||||
; (X2 >= 0) && (X2 < XRES)
|
||||
; (Y1 >= 0) && (Y1 < YRES)
|
||||
; (Y2 >= 0) && (Y2 < YRES)
|
||||
; X1 <= X2
|
||||
; Y1 <= Y2
|
||||
; (X1 >= 0) && (X1 < XRES)
|
||||
; (X2 >= 0) && (X2 < XRES)
|
||||
; (Y1 >= 0) && (Y1 < YRES)
|
||||
; (Y2 >= 0) && (Y2 < YRES)
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
|
||||
BAR:
|
||||
inc Y2
|
||||
@L1: lda X1
|
||||
pha
|
||||
@L2: jsr SETPIXEL
|
||||
inc X1
|
||||
lda X2
|
||||
cmp X1
|
||||
bne @L2
|
||||
pla
|
||||
sta X1
|
||||
inc Y1
|
||||
lda Y2
|
||||
cmp Y1
|
||||
bne @L1
|
||||
rts
|
||||
inc Y2
|
||||
@L1: lda X1
|
||||
pha
|
||||
@L2: jsr SETPIXEL
|
||||
inc X1
|
||||
lda X2
|
||||
cmp X1
|
||||
bne @L2
|
||||
pla
|
||||
sta X1
|
||||
inc Y1
|
||||
lda Y2
|
||||
cmp Y1
|
||||
bne @L1
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y
|
||||
@@ -416,7 +416,7 @@ BAR:
|
||||
;
|
||||
|
||||
TEXTSTYLE:
|
||||
rts
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the
|
||||
@@ -427,68 +427,68 @@ TEXTSTYLE:
|
||||
;
|
||||
|
||||
OUTTEXT:
|
||||
lda ptr1
|
||||
lsr
|
||||
tay
|
||||
lda ptr2
|
||||
lsr
|
||||
tax
|
||||
clc
|
||||
jsr setcursor
|
||||
ldy #0
|
||||
@L1: lda (ptr3),y
|
||||
jsr putchar
|
||||
iny
|
||||
cmp #$0
|
||||
bne @L1
|
||||
rts
|
||||
lda ptr1
|
||||
lsr
|
||||
tay
|
||||
lda ptr2
|
||||
lsr
|
||||
tax
|
||||
clc
|
||||
jsr setcursor
|
||||
ldy #0
|
||||
@L1: lda (ptr3),y
|
||||
jsr putchar
|
||||
iny
|
||||
cmp #$0
|
||||
bne @L1
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Calculate all variables to plot the pixel at X1/Y1. If the point is out
|
||||
; of range, a carry is returned and INRANGE is set to a value !0 zero. If
|
||||
; the coordinates are valid, INRANGE is zero and the carry clear.
|
||||
|
||||
CALC: lda xres
|
||||
sta TEMP
|
||||
lda #0
|
||||
sta TEMP+1
|
||||
ldy Y1
|
||||
@L1: lda TEMP
|
||||
add xres
|
||||
lsr
|
||||
sta TEMP
|
||||
lda TEMP+1
|
||||
adc #0
|
||||
lsr
|
||||
sta TEMP+1
|
||||
dey
|
||||
bne @L1
|
||||
lda TEMP
|
||||
add X1
|
||||
lsr
|
||||
sta TEMP
|
||||
lda TEMP+1
|
||||
adc #0
|
||||
lsr
|
||||
sta TEMP+1
|
||||
lda TEMP
|
||||
add #<MEM
|
||||
sta TEMP
|
||||
lda TEMP+1
|
||||
adc #>MEM
|
||||
sta TEMP+1
|
||||
CALC: lda xres
|
||||
sta TEMP
|
||||
lda #0
|
||||
sta TEMP+1
|
||||
ldy Y1
|
||||
@L1: lda TEMP
|
||||
add xres
|
||||
lsr
|
||||
sta TEMP
|
||||
lda TEMP+1
|
||||
adc #0
|
||||
lsr
|
||||
sta TEMP+1
|
||||
dey
|
||||
bne @L1
|
||||
lda TEMP
|
||||
add X1
|
||||
lsr
|
||||
sta TEMP
|
||||
lda TEMP+1
|
||||
adc #0
|
||||
lsr
|
||||
sta TEMP+1
|
||||
lda TEMP
|
||||
add #<MEM
|
||||
sta TEMP
|
||||
lda TEMP+1
|
||||
adc #>MEM
|
||||
sta TEMP+1
|
||||
|
||||
lda X1
|
||||
and #%00000001
|
||||
sta TEMP3
|
||||
lda Y1
|
||||
asl
|
||||
and #%00000010
|
||||
ora TEMP3
|
||||
tax
|
||||
lda OFFSET,x
|
||||
rts
|
||||
lda X1
|
||||
and #%00000001
|
||||
sta TEMP3
|
||||
lda Y1
|
||||
asl
|
||||
and #%00000010
|
||||
ora TEMP3
|
||||
tax
|
||||
lda OFFSET,x
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.include "../../tgi/tgidrv_line.inc"
|
||||
.include "../../tgi/tgidrv_line.inc"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
; Target-specific black & white values for use by the target-shared TGI kernel
|
||||
;
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-kernel.inc"
|
||||
|
||||
.export tgi_color_black:zp = $00
|
||||
.export tgi_color_white:zp = $01
|
||||
.export tgi_color_black:zp = $00
|
||||
.export tgi_color_white:zp = $01
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const void tgi_static_stddrv[];
|
||||
;
|
||||
|
||||
.export _tgi_static_stddrv
|
||||
.import _nes_64_56_2_tgi
|
||||
.export _tgi_static_stddrv
|
||||
.import _nes_64_56_2_tgi
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const char tgi_stddrv[];
|
||||
;
|
||||
|
||||
.export _tgi_stddrv
|
||||
.export _tgi_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_tgi_stddrv: .asciiz "nes-64-56-2.tgi"
|
||||
_tgi_stddrv: .asciiz "nes-64-56-2.tgi"
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
; void waitvblank(void);
|
||||
;
|
||||
|
||||
.export _waitvblank
|
||||
.export _waitvblank
|
||||
|
||||
.include "nes.inc"
|
||||
.include "nes.inc"
|
||||
|
||||
.proc _waitvblank
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
; unsigned char wherex (void);
|
||||
;
|
||||
|
||||
.export _wherex
|
||||
.export _wherex
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
lda CURS_X
|
||||
ldx #$00
|
||||
rts
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
; unsigned char wherey (void);
|
||||
;
|
||||
|
||||
.export _wherey
|
||||
.export _wherey
|
||||
|
||||
.include "nes.inc"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
lda CURS_Y
|
||||
ldx #$00
|
||||
rts
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user