o crc checking rom
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
# SDK Config
|
||||
|
||||
# Linux Wine
|
||||
SDK=/home/david/.wine/drive_c/65xx_FreeSDK
|
||||
WINE=wine
|
||||
EMU=zsnes
|
||||
EMU_DEBUG=/home/david/Devel/arch/snes/tools/zsnes_linux_debug151/src/zsnesd -d
|
||||
|
||||
|
||||
# OSX Crossover Office
|
||||
SDK=/Users/david/.wine/drive_c/65xx_FreeSDK
|
||||
CC=/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wineloader winewrapper.exe --wait-children --start -- C:/65xx_FreeSDK/bin/WDC816CC.exe
|
||||
AS=/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wineloader winewrapper.exe --wait-children --start -- C:/65xx_FreeSDK/bin/WDC816AS.exe
|
||||
LD=/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wineloader winewrapper.exe --wait-children --start -- C:/65xx_FreeSDK/bin/WDCLN.exe
|
||||
EMU=zsnes
|
||||
|
||||
# Mac Wine
|
||||
SDK=/Users/david/.wine/drive_c/65xx_FreeSDK
|
||||
WINE=wine
|
||||
EMU=zsnes
|
||||
CC=$(WINE) $(SDK)/bin/WDC816CC.exe
|
||||
AS=$(WINE) $(SDK)/bin/WDC816AS.exe
|
||||
LD=$(WINE) $(SDK)/bin/WDCLN.exe
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PADBIN=$(WINE) tools/padbin.exe
|
||||
PCX2SNES=$(WINE) tools/Pcx2Snes.exe
|
||||
|
||||
# Project
|
||||
INC=$(SDK)/include
|
||||
LIBS=$(SDK)/lib/cs
|
||||
#OBJS=StartupSnes.obj main.obj pad.obj event.obj myEvents.obj PPU.obj debug.obj ressource.obj
|
||||
OBJS=StartupSnes.obj main.obj pad.obj PPU.obj debug.obj ressource.obj crc.obj
|
||||
APP=crc.smc
|
||||
GFX=kungfu debugfont
|
||||
|
||||
all: $(APP)
|
||||
|
||||
run:
|
||||
$(EMU) $(APP)
|
||||
|
||||
debugger:
|
||||
$(EMU_DEBUG) $(APP)
|
||||
|
||||
upload:
|
||||
ucon64 $(APP)
|
||||
cp -rv $(APP) /Volumes/SNES
|
||||
sync
|
||||
diskutil unmount /Volumes/SNES
|
||||
|
||||
|
||||
kungfu:
|
||||
$(PCX2SNES) ressource/kungfu -n -c16 -screen
|
||||
|
||||
debugfont:
|
||||
$(PCX2SNES) ressource/debugFont -n -c16 -s8 -o1
|
||||
|
||||
%.obj: %.asm
|
||||
$(AS) -V $?
|
||||
|
||||
%.obj: %.c
|
||||
$(CC) -wl -wp -sop -MS -I $(INC) $?
|
||||
|
||||
$(APP): $(OBJS)
|
||||
$(LD) -HB -M21 -V -T -Pff \
|
||||
-C008000,0000 -U0000,0000 \
|
||||
-Avectors=FFE4,7FE4 \
|
||||
-Aregistration_data=FFB0,7FB0 \
|
||||
-Aressource=18000,8000 \
|
||||
-N $(OBJS) -L$(LIBS) -O $@
|
||||
$(PADBIN) 0x40000 $(APP)
|
||||
|
||||
clean:
|
||||
rm -vf $(APP) *.obj
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "data.h"
|
||||
|
||||
byte tileMapLocation[4];
|
||||
word characterLocation[4];
|
||||
|
||||
void waitForVBlank(void) {
|
||||
byte Status;
|
||||
do {
|
||||
Status = *(byte*)0x4210;
|
||||
} while (!(Status & 0x80));
|
||||
}
|
||||
|
||||
void setTileMapLocation(word vramDst, byte screenProp, byte bgNumber) {
|
||||
tileMapLocation[bgNumber] = ((vramDst >> 8) & 0xfc) | ( screenProp & 0x03 );
|
||||
*(byte*) (0x2107+bgNumber) = tileMapLocation[bgNumber];
|
||||
}
|
||||
|
||||
void restoreTileMapLocation(byte bgNumber) {
|
||||
*(byte*) (0x2107+bgNumber) = tileMapLocation[bgNumber];
|
||||
}
|
||||
|
||||
void setCharacterLocation(word vramDst, byte bgNumber) {
|
||||
characterLocation[bgNumber] = vramDst;
|
||||
if(bgNumber < 2) {
|
||||
*(byte*) 0x210b = (characterLocation[1] >> 8 & 0xf0 ) + (characterLocation[0] >> 12);
|
||||
} else {
|
||||
*(byte*) 0x210c = (characterLocation[3] >> 8 & 0xf0 ) + (characterLocation[2] >> 12);
|
||||
}
|
||||
}
|
||||
|
||||
void restoreCharacterLocation(byte bgNumber) {
|
||||
setCharacterLocation(characterLocation[bgNumber], bgNumber);
|
||||
}
|
||||
|
||||
void VRAMByteWrite(byte value, word vramDst) {
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = vramDst;
|
||||
|
||||
*(byte*)0x2118 = value;
|
||||
}
|
||||
|
||||
void VRAMLoad(word src, word vramDst, word size) {
|
||||
// set address in VRam for read or write ($2116) + block size transfer ($2115)
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = vramDst;
|
||||
|
||||
*(word*)0x4300 = 0x1801; // set DMA control register (1 word inc)
|
||||
// and destination ($21xx xx -> 0x18)
|
||||
*(word*)0x4302 = src; // DMA channel x source address offset
|
||||
// (low $4302 and high $4303 optimisation)
|
||||
*(byte*)0x4304 = 0x01; // DMA channel x source address bank
|
||||
*(word*)0x4305 = size; // DMA channel x transfer size
|
||||
// (low $4305 and high $4306 optimisation)
|
||||
|
||||
// Turn on DMA transfer for this channel
|
||||
waitForVBlank();
|
||||
*(byte*)0x2100 = 0x80;
|
||||
*(byte*)0x420b = 0x01;
|
||||
*(byte*)0x2100 = 0x00;
|
||||
}
|
||||
|
||||
void CGRAMLoad(word src, byte cgramDst, word size) {
|
||||
|
||||
// set address in VRam for read or write + block size
|
||||
*(byte*)0x2121 = cgramDst;
|
||||
|
||||
*(word*)0x4300 = 0x2200; // set DMA control register (1 byte inc)
|
||||
// and destination ($21xx xx -> 022)
|
||||
*(word*)0x4302 = src; // DMA channel x source address offset
|
||||
// (low $4302 and high $4303 optimisation)
|
||||
*(byte*)0x4304 = 0x01; // DMA channel x source address bank
|
||||
*(word*)0x4305 = size; // DMA channel x transfer size
|
||||
// (low $4305 and high $4306 optimisation)
|
||||
|
||||
// Turn on DMA transfer for this channel
|
||||
waitForVBlank();
|
||||
*(byte*)0x2100 = 0x80;
|
||||
*(byte*)0x420b = 0x01;
|
||||
*(byte*)0x2100 = 0x00;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
extern byte tileMapLocation[4];
|
||||
extern word characterLocation[4];
|
||||
|
||||
void waitForVBlank(void);
|
||||
void setTileMapLocation(word vramDst, byte screenProp, byte bgNumber);
|
||||
void restoreTileMapLocation(byte bgNumber);
|
||||
void setCharacterLocation(word vramDst, byte bgNumber);
|
||||
void restoreCharacterLocation(byte bgNumber);
|
||||
void VRAMByteWrite(byte value, word vramDst);
|
||||
void VRAMLoad(word src, word vramDst, word size);
|
||||
void CGRAMLoad(word src, byte cgramDst, word size);
|
||||
@@ -0,0 +1,240 @@
|
||||
; SNES ROM startup code
|
||||
|
||||
;******************************************************************************
|
||||
;*** Define a special section in case most of the code is not in bank 0. ***
|
||||
;******************************************************************************
|
||||
|
||||
;STACK EQU $01ff ;CHANGE THIS FOR YOUR SYSTEM
|
||||
|
||||
;STARTUP SECTION OFFSET $008000
|
||||
|
||||
CODE
|
||||
|
||||
XDEF START
|
||||
START:
|
||||
XREF __main
|
||||
|
||||
sei ; Disabled interrupts
|
||||
clc ; clear carry to switch to native mode
|
||||
xce ; Xchange carry & emulation bit. native mode
|
||||
rep #$18 ; Binary mode (decimal mode off), X/Y 16 bit
|
||||
LONGI ON
|
||||
ldx #$1FFF ; set stack to $1FFF
|
||||
txs
|
||||
|
||||
rep #$30
|
||||
longa on
|
||||
longi on
|
||||
|
||||
; Init data used for heap
|
||||
; see heap definition below
|
||||
XREF ___heap_top
|
||||
XREF ___mem_start
|
||||
stz ___heap_top
|
||||
stz ___mem_start
|
||||
|
||||
XREF __preInit
|
||||
jsr >__preInit
|
||||
|
||||
sep #$30 ; X,Y,A are 8 bit numbers
|
||||
LONGA OFF
|
||||
LONGI OFF
|
||||
lda #$8F ; screen off, full brightness
|
||||
sta $2100 ; brightness + screen enable register
|
||||
stz $2101 ; Sprite register (size + address in VRAM)
|
||||
stz $2102 ; Sprite registers (address of sprite memory [OAM])
|
||||
stz $2103 ; "" ""
|
||||
stz $2105 ; Mode 0, = Graphic mode register
|
||||
stz $2106 ; noplanes, no mosaic, = Mosaic register
|
||||
stz $2107 ; Plane 0 map VRAM location
|
||||
stz $2108 ; Plane 1 map VRAM location
|
||||
stz $2109 ; Plane 2 map VRAM location
|
||||
stz $210A ; Plane 3 map VRAM location
|
||||
stz $210B ; Plane 0+1 Tile data location
|
||||
stz $210C ; Plane 2+3 Tile data location
|
||||
stz $210D ; Plane 0 scroll x (first 8 bits)
|
||||
stz $210D ; Plane 0 scroll x (last 3 bits) #$0 - #$07ff
|
||||
stz $210E ; Plane 0 scroll y (first 8 bits)
|
||||
stz $210E ; Plane 0 scroll y (last 3 bits) #$0 - #$07ff
|
||||
stz $210F ; Plane 1 scroll x (first 8 bits)
|
||||
stz $210F ; Plane 1 scroll x (last 3 bits) #$0 - #$07ff
|
||||
stz $2110 ; Plane 1 scroll y (first 8 bits)
|
||||
stz $2110 ; Plane 1 scroll y (last 3 bits) #$0 - #$07ff
|
||||
stz $2111 ; Plane 2 scroll x (first 8 bits)
|
||||
stz $2111 ; Plane 2 scroll x (last 3 bits) #$0 - #$07ff
|
||||
stz $2112 ; Plane 2 scroll y (first 8 bits)
|
||||
stz $2112 ; Plane 2 scroll y (last 3 bits) #$0 - #$07ff
|
||||
stz $2113 ; Plane 3 scroll x (first 8 bits)
|
||||
stz $2113 ; Plane 3 scroll x (last 3 bits) #$0 - #$07ff
|
||||
stz $2114 ; Plane 3 scroll y (first 8 bits)
|
||||
stz $2114 ; Plane 3 scroll y (last 3 bits) #$0 - #$07ff
|
||||
lda #$80 ; increase VRAM address after writing to $2119
|
||||
sta $2115 ; VRAM address increment register
|
||||
stz $2116 ; VRAM address low
|
||||
stz $2117 ; VRAM address high
|
||||
stz $211A ; Initial Mode 7 setting register
|
||||
stz $211B ; Mode 7 matrix parameter A register (low)
|
||||
lda #$01
|
||||
sta $211B ; Mode 7 matrix parameter A register (high)
|
||||
stz $211C ; Mode 7 matrix parameter B register (low)
|
||||
stz $211C ; Mode 7 matrix parameter B register (high)
|
||||
stz $211D ; Mode 7 matrix parameter C register (low)
|
||||
stz $211D ; Mode 7 matrix parameter C register (high)
|
||||
stz $211E ; Mode 7 matrix parameter D register (low)
|
||||
sta $211E ; Mode 7 matrix parameter D register (high)
|
||||
stz $211F ; Mode 7 center position X register (low)
|
||||
stz $211F ; Mode 7 center position X register (high)
|
||||
stz $2120 ; Mode 7 center position Y register (low)
|
||||
stz $2120 ; Mode 7 center position Y register (high)
|
||||
stz $2121 ; Color number register ($0-ff)
|
||||
stz $2123 ; BG1 & BG2 Window mask setting register
|
||||
stz $2124 ; BG3 & BG4 Window mask setting register
|
||||
stz $2125 ; OBJ & Color Window mask setting register
|
||||
stz $2126 ; Window 1 left position register
|
||||
stz $2127 ; Window 2 left position register
|
||||
stz $2128 ; Window 3 left position register
|
||||
stz $2129 ; Window 4 left position register
|
||||
stz $212A ; BG1, BG2, BG3, BG4 Window Logic register
|
||||
stz $212B ; OBJ, Color Window Logic Register (or,and,xor,xnor)
|
||||
sta $212C ; Main Screen designation (planes, sprites enable)
|
||||
stz $212D ; Sub Screen designation
|
||||
stz $212E ; Window mask for Main Screen
|
||||
stz $212F ; Window mask for Sub Screen
|
||||
lda #$30
|
||||
sta $2130 ; Color addition & screen addition init setting
|
||||
stz $2131 ; Add/Sub sub designation for screen, sprite, color
|
||||
lda #$E0
|
||||
sta $2132 ; color data for addition/subtraction
|
||||
stz $2133 ; Screen setting (interlace x,y/enable SFX data)
|
||||
stz $4200 ; Enable V-blank, interrupt, Joypad register
|
||||
lda #$FF
|
||||
sta $4201 ; Programmable I/O port
|
||||
stz $4202 ; Multiplicand A
|
||||
stz $4203 ; Multiplier B
|
||||
stz $4204 ; Multiplier C
|
||||
stz $4205 ; Multiplicand C
|
||||
stz $4206 ; Divisor B
|
||||
stz $4207 ; Horizontal Count Timer
|
||||
stz $4208 ; Horizontal Count Timer MSB (most significant bit)
|
||||
stz $4209 ; Vertical Count Timer
|
||||
stz $420A ; Vertical Count Timer MSB
|
||||
stz $420B ; General DMA enable (bits 0-7)
|
||||
stz $420C ; Horizontal DMA (HDMA) enable (bits 0-7)
|
||||
stz $420D ; Access cycle designation (slow/fast rom)
|
||||
cli ; Enable interrupts
|
||||
|
||||
rep #$30
|
||||
longa on
|
||||
longi on
|
||||
|
||||
jsr >__main
|
||||
brk
|
||||
|
||||
XDEF IRQ
|
||||
IRQ:
|
||||
XREF __IRQHandler
|
||||
LONGA ON
|
||||
LONGI ON
|
||||
rep #$30
|
||||
pha
|
||||
phx
|
||||
phy
|
||||
jsr __IRQHandler
|
||||
ply
|
||||
plx
|
||||
pla
|
||||
rti
|
||||
|
||||
XDEF NMI
|
||||
NMI:
|
||||
XREF __NMIHandler
|
||||
LONGA ON
|
||||
LONGI ON
|
||||
rep #$30
|
||||
pha
|
||||
phx
|
||||
phy
|
||||
phd
|
||||
phb
|
||||
lda #$0000
|
||||
sep #$30 ; X,Y,A are 8 bit numbers
|
||||
LONGA OFF
|
||||
LONGI OFF
|
||||
lda $4210 ; Read NMI
|
||||
LONGA ON
|
||||
LONGI ON
|
||||
rep #$30
|
||||
jsr __NMIHandler
|
||||
plb
|
||||
pld
|
||||
ply
|
||||
plx
|
||||
pla
|
||||
rti
|
||||
|
||||
DIRQ:
|
||||
rti
|
||||
|
||||
ENDS
|
||||
|
||||
;******************************************************************************
|
||||
;*** Heap definition ***
|
||||
;******************************************************************************
|
||||
|
||||
DATA
|
||||
|
||||
XDEF __heap_start
|
||||
XDEF __heap_end
|
||||
|
||||
__heap_start:
|
||||
WORD $1000
|
||||
__heap_end:
|
||||
WORD $1200
|
||||
|
||||
;******************************************************************************
|
||||
;*** SNES ROM Registartion Data ***
|
||||
;******************************************************************************
|
||||
|
||||
REGISTRATION_DATA SECTION
|
||||
|
||||
MAKER_CODE FCC /FF/
|
||||
GAME_CODE FCC /SMWJ/
|
||||
FIXED_VALUE0 BYTE $00, $00, $00, $00, $00, $00, $00
|
||||
EXPANSION_RAM_SIZE BYTE $00
|
||||
SPECIAL_VERSION BYTE $00
|
||||
CARTRIDGE_TYPE_SUB BYTE $00
|
||||
GAME_TITLE FCC /GAME TITLE !/
|
||||
;012345678901234567890;
|
||||
MAP_MODE BYTE $20
|
||||
CARTRIDGE_SIZE BYTE $00
|
||||
ROM_SIZE BYTE $08
|
||||
RAM_SIZE BYTE $00
|
||||
DESTINATION_CODE BYTE $00
|
||||
FIXED_VALUE1 BYTE $33
|
||||
MASK_ROM_VERSION BYTE $00
|
||||
COMPLEMENT_CHECK BYTE $00, $00
|
||||
CHEKSUM BYTE $00, $00
|
||||
|
||||
;******************************************************************************
|
||||
;*** SNES Interrupts and Reset vector ***
|
||||
;******************************************************************************
|
||||
|
||||
VECTORS SECTION
|
||||
; Native vector
|
||||
N_COP DW DIRQ
|
||||
N_BRK DW DIRQ
|
||||
N_ABORT DW DIRQ
|
||||
N_NMI DW NMI
|
||||
N_RSRVD DW DIRQ
|
||||
N_IRQ DW IRQ
|
||||
DS 4
|
||||
; Emulation vector
|
||||
E_COP DW DIRQ
|
||||
E_RSRVD DW DIRQ
|
||||
E_ABORT DW DIRQ
|
||||
E_NMI DW DIRQ
|
||||
E_RESET DW START
|
||||
E_IRQ DW DIRQ
|
||||
|
||||
END
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
;:ts=8
|
||||
R0 equ 1
|
||||
R1 equ 5
|
||||
R2 equ 9
|
||||
R3 equ 13
|
||||
code
|
||||
xdef __initInternalRegisters
|
||||
func
|
||||
__initInternalRegisters:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L2
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
stz |__characterLocation
|
||||
stz |__characterLocation+2
|
||||
stz |__characterLocation+4
|
||||
stz |__characterLocation+6
|
||||
jsr __initDebugMap
|
||||
L4:
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L2
|
||||
tcs
|
||||
rts
|
||||
L2 equ 0
|
||||
L3 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __preInit
|
||||
func
|
||||
__preInit:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L5
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
L7:
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L5
|
||||
tcs
|
||||
rts
|
||||
L5 equ 0
|
||||
L6 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __main
|
||||
func
|
||||
__main:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L8
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
jsr __initInternalRegisters
|
||||
pea #<$0
|
||||
pea #<$0
|
||||
pea #<$1000
|
||||
jsr __setTileMapLocation
|
||||
pea #<$0
|
||||
pea #<$2000
|
||||
jsr __setCharacterLocation
|
||||
pea #<$100
|
||||
pea #<$0
|
||||
lda #<__title_pal
|
||||
pha
|
||||
jsr __CGRAMLoad
|
||||
sep #$20
|
||||
longa off
|
||||
lda #$1
|
||||
sta |8453
|
||||
rep #$20
|
||||
longa on
|
||||
sep #$20
|
||||
longa off
|
||||
lda #$1
|
||||
sta |8492
|
||||
rep #$20
|
||||
longa on
|
||||
sep #$20
|
||||
longa off
|
||||
lda #$0
|
||||
sta |8493
|
||||
rep #$20
|
||||
longa on
|
||||
sep #$20
|
||||
longa off
|
||||
lda #$f
|
||||
sta |8448
|
||||
rep #$20
|
||||
longa on
|
||||
stz |__currentScrollEvent
|
||||
stz |__scrollValue
|
||||
jsr __debug
|
||||
L10001:
|
||||
brl L10001
|
||||
L8 equ 0
|
||||
L9 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __IRQHandler
|
||||
func
|
||||
__IRQHandler:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L10
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
L12:
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L10
|
||||
tcs
|
||||
rts
|
||||
L10 equ 0
|
||||
L11 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __NMIHandler
|
||||
func
|
||||
__NMIHandler:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L13
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
L15:
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L13
|
||||
tcs
|
||||
rts
|
||||
L13 equ 0
|
||||
L14 equ 1
|
||||
ends
|
||||
efunc
|
||||
xref __debug
|
||||
xref __initDebugMap
|
||||
xref __CGRAMLoad
|
||||
xref __setCharacterLocation
|
||||
xref __setTileMapLocation
|
||||
udata
|
||||
xdef __scrollValue
|
||||
__scrollValue
|
||||
ds 2
|
||||
ends
|
||||
udata
|
||||
xdef __currentScrollEvent
|
||||
__currentScrollEvent
|
||||
ds 2
|
||||
ends
|
||||
udata
|
||||
xdef __pad1
|
||||
__pad1
|
||||
ds 2
|
||||
ends
|
||||
xref __characterLocation
|
||||
xref __title_pal
|
||||
end
|
||||
@@ -0,0 +1,183 @@
|
||||
;:ts=8
|
||||
R0 equ 1
|
||||
R1 equ 5
|
||||
R2 equ 9
|
||||
R3 equ 13
|
||||
code
|
||||
xdef __initInternalRegisters
|
||||
func
|
||||
__initInternalRegisters:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L2
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
stz |__characterLocation
|
||||
stz |__characterLocation+2
|
||||
stz |__characterLocation+4
|
||||
stz |__characterLocation+6
|
||||
jsr __initDebugMap
|
||||
L4:
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L2
|
||||
tcs
|
||||
rts
|
||||
L2 equ 0
|
||||
L3 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __preInit
|
||||
func
|
||||
__preInit:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L5
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
L7:
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L5
|
||||
tcs
|
||||
rts
|
||||
L5 equ 0
|
||||
L6 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __main
|
||||
func
|
||||
__main:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L8
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
jsr __initInternalRegisters
|
||||
pea #<$0
|
||||
pea #<$0
|
||||
pea #<$1000
|
||||
jsr __setTileMapLocation
|
||||
pea #<$0
|
||||
pea #<$2000
|
||||
jsr __setCharacterLocation
|
||||
pea #<$100
|
||||
pea #<$0
|
||||
lda #<__title_pal
|
||||
pha
|
||||
jsr __CGRAMLoad
|
||||
sep #$20
|
||||
longa off
|
||||
lda #$1
|
||||
sta |8453
|
||||
rep #$20
|
||||
longa on
|
||||
sep #$20
|
||||
longa off
|
||||
lda #$1
|
||||
sta |8492
|
||||
rep #$20
|
||||
longa on
|
||||
sep #$20
|
||||
longa off
|
||||
lda #$0
|
||||
sta |8493
|
||||
rep #$20
|
||||
longa on
|
||||
sep #$20
|
||||
longa off
|
||||
lda #$f
|
||||
sta |8448
|
||||
rep #$20
|
||||
longa on
|
||||
stz |__currentScrollEvent
|
||||
stz |__scrollValue
|
||||
jsr __debug
|
||||
L10001:
|
||||
brl L10001
|
||||
L8 equ 0
|
||||
L9 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __IRQHandler
|
||||
func
|
||||
__IRQHandler:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L10
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
L12:
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L10
|
||||
tcs
|
||||
rts
|
||||
L10 equ 0
|
||||
L11 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __NMIHandler
|
||||
func
|
||||
__NMIHandler:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L13
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
L15:
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L13
|
||||
tcs
|
||||
rts
|
||||
L13 equ 0
|
||||
L14 equ 1
|
||||
ends
|
||||
efunc
|
||||
xref __debug
|
||||
xref __initDebugMap
|
||||
xref __CGRAMLoad
|
||||
xref __setCharacterLocation
|
||||
xref __setTileMapLocation
|
||||
udata
|
||||
xdef __scrollValue
|
||||
__scrollValue
|
||||
ds 2
|
||||
ends
|
||||
udata
|
||||
xdef __currentScrollEvent
|
||||
__currentScrollEvent
|
||||
ds 2
|
||||
ends
|
||||
udata
|
||||
xdef __pad1
|
||||
__pad1
|
||||
ds 2
|
||||
ends
|
||||
xref __characterLocation
|
||||
xref __title_pal
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "data.h"
|
||||
|
||||
|
||||
word crc_update (byte *data, word size)
|
||||
{
|
||||
word i;
|
||||
word j;
|
||||
word crc=0;
|
||||
for (j=0; j<size; j++){
|
||||
crc = crc ^ ((word)data[j]<< 8);
|
||||
for (i=0; i<8; i++){
|
||||
if (crc & 0x8000)
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
else
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
word crc_update_mem (word addr, word size)
|
||||
{
|
||||
word i;
|
||||
word j;
|
||||
word crc=0;
|
||||
word v;
|
||||
for (j=0; j<size; j++){
|
||||
v = addr;
|
||||
crc = crc ^ ((word)v<< 8);
|
||||
for (i=0; i<8; i++){
|
||||
if (crc & 0x8000)
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
else
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
word crc_update (byte *data, word size);
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "data.h"
|
||||
#include "pad.h"
|
||||
#include "PPU.h"
|
||||
#include "ressource.h"
|
||||
#include "crc.h"
|
||||
|
||||
word debugMap[0x400];
|
||||
|
||||
void initDebugMap(void) {
|
||||
word i;
|
||||
for(i=0; i<0x400; i++) {
|
||||
debugMap[i] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void int2hex(word i, char *buf)
|
||||
{
|
||||
word a;
|
||||
for (a = 0; a < 4; ++a) {
|
||||
buf[a] = (i >> (4 * (2 * 2 - 1 - a))) & 0xf;
|
||||
if (buf[a] < 10)
|
||||
buf[a] += '0';
|
||||
else
|
||||
buf[a] += 'A' - 10;
|
||||
}
|
||||
buf[a] = 0;
|
||||
}
|
||||
|
||||
void debug(void) {
|
||||
word i,j;
|
||||
word crc01;
|
||||
word crc02;
|
||||
padStatus pad1;
|
||||
char line_header[32] = "BANK CRC ADDR 123456789ABCDEF";
|
||||
char line[32] = " ";
|
||||
char test_buffer[] = "da";
|
||||
void *pointer;
|
||||
|
||||
VRAMLoad((word) debugFont_pic, 0x5000, 2048);
|
||||
CGRAMLoad((word) debugFont_pal, (byte) 0x00, (word) 16);
|
||||
VRAMLoad((word) debugMap, 0x4000, 0x0800);
|
||||
setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
|
||||
setCharacterLocation(0x5000, (byte) 0);
|
||||
*(byte*) 0x2100 = 0x0f; // enable background
|
||||
|
||||
j=0;
|
||||
waitForVBlank();
|
||||
for(i=0; i<32; i++) {
|
||||
waitForVBlank();
|
||||
VRAMByteWrite((byte) (line_header[i]-32), (word) (0x4000+i+(j*0x20)));
|
||||
}
|
||||
|
||||
while(1){
|
||||
pointer = (void*)0x8000;
|
||||
crc02 = crc_update(test_buffer,2);
|
||||
//crc01 = crc_update(pointer,255);
|
||||
for(j=0; j<8; j++) {
|
||||
crc01 = crc_update(pointer,0x8000);
|
||||
int2hex(j,&line[0]);
|
||||
int2hex(crc01,&line[5]);
|
||||
int2hex((word)pointer,&line[10]);
|
||||
waitForVBlank();
|
||||
for(i=0; i<32; i++) {
|
||||
waitForVBlank();
|
||||
VRAMByteWrite((byte) (line[i]-32), (word) (0x4000+i+((j+1)*0x20)));
|
||||
}
|
||||
//pointer+=0x010000;
|
||||
}
|
||||
while(!pad1.start) {
|
||||
waitForVBlank();
|
||||
pad1 = readPad((byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma section CODE=BANK3,offset $3:0000
|
||||
char far dummy[128];
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
void initDebugMap(void);
|
||||
void debug(void);
|
||||
@@ -0,0 +1,294 @@
|
||||
;:ts=8
|
||||
R0 equ 1
|
||||
R1 equ 5
|
||||
R2 equ 9
|
||||
R3 equ 13
|
||||
code
|
||||
xdef __initEvents
|
||||
func
|
||||
__initEvents:
|
||||
longa on
|
||||
longi on
|
||||
stz |__events
|
||||
rts
|
||||
L2 equ 0
|
||||
L3 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __createEvent
|
||||
func
|
||||
__createEvent:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L5
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
callback_0 set 3
|
||||
myEvent_1 set 0
|
||||
pea #<$8
|
||||
jsr __malloc
|
||||
sta <L6+myEvent_1
|
||||
lda #$0
|
||||
sta (<L6+myEvent_1)
|
||||
lda <L5+callback_0
|
||||
ldy #$2
|
||||
sta (<L6+myEvent_1),Y
|
||||
lda #$0
|
||||
ldy #$6
|
||||
sta (<L6+myEvent_1),Y
|
||||
dey
|
||||
dey
|
||||
sta (<L6+myEvent_1),Y
|
||||
lda <L6+myEvent_1
|
||||
tay
|
||||
lda <L5+1
|
||||
sta <L5+1+2
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L5+2
|
||||
tcs
|
||||
tya
|
||||
rts
|
||||
L5 equ 2
|
||||
L6 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __addEvent
|
||||
func
|
||||
__addEvent:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L8
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
callback_0 set 3
|
||||
noDuplicateCallback_0 set 5
|
||||
lastEvent_1 set 0
|
||||
myEvent_1 set 2
|
||||
lda |__events
|
||||
bne L10001
|
||||
pei <L8+callback_0
|
||||
jsr __createEvent
|
||||
sta |__events
|
||||
L11:
|
||||
tay
|
||||
lda <L8+1
|
||||
sta <L8+1+4
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L8+4
|
||||
tcs
|
||||
tya
|
||||
rts
|
||||
L10001:
|
||||
lda |__events
|
||||
bra L20000
|
||||
L20004:
|
||||
ldy #$2
|
||||
lda (<L9+lastEvent_1),Y
|
||||
cmp <L8+callback_0
|
||||
bne L10005
|
||||
L20005:
|
||||
lda #$0
|
||||
bra L11
|
||||
L20002:
|
||||
lda <L8+noDuplicateCallback_0
|
||||
cmp #<$1
|
||||
bne L10004
|
||||
ldy #$2
|
||||
lda (<L9+lastEvent_1),Y
|
||||
cmp <L8+callback_0
|
||||
beq L20005
|
||||
L10004:
|
||||
ldy #$6
|
||||
lda (<L9+lastEvent_1),Y
|
||||
L20000:
|
||||
sta <L9+lastEvent_1
|
||||
ldy #$6
|
||||
lda (<L9+lastEvent_1),Y
|
||||
bne L20002
|
||||
lda <L8+noDuplicateCallback_0
|
||||
cmp #<$1
|
||||
beq L20004
|
||||
L10005:
|
||||
pei <L8+callback_0
|
||||
jsr __createEvent
|
||||
sta <L9+myEvent_1
|
||||
lda <L9+lastEvent_1
|
||||
ldy #$4
|
||||
sta (<L9+myEvent_1),Y
|
||||
lda <L9+myEvent_1
|
||||
iny
|
||||
iny
|
||||
sta (<L9+lastEvent_1),Y
|
||||
lda <L9+myEvent_1
|
||||
bra L11
|
||||
L8 equ 4
|
||||
L9 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __removeEvent
|
||||
func
|
||||
__removeEvent:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L17
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
eventElement_0 set 3
|
||||
alone_1 set 0
|
||||
next_1 set 1
|
||||
previous_1 set 3
|
||||
sep #$20
|
||||
longa off
|
||||
stz <L18+alone_1
|
||||
rep #$20
|
||||
longa on
|
||||
ldy #$6
|
||||
lda (<L17+eventElement_0),Y
|
||||
sta <L18+next_1
|
||||
dey
|
||||
dey
|
||||
lda (<L17+eventElement_0),Y
|
||||
sta <L18+previous_1
|
||||
iny
|
||||
iny
|
||||
lda (<L17+eventElement_0),Y
|
||||
beq L10006
|
||||
dey
|
||||
dey
|
||||
lda (<L17+eventElement_0),Y
|
||||
beq L10006
|
||||
sep #$20
|
||||
longa off
|
||||
inc <L18+alone_1
|
||||
rep #$20
|
||||
longa on
|
||||
lda <L18+previous_1
|
||||
sta (<L18+next_1),Y
|
||||
lda <L18+next_1
|
||||
bra L20007
|
||||
L10006:
|
||||
ldy #$6
|
||||
lda (<L17+eventElement_0),Y
|
||||
beq L10008
|
||||
sep #$20
|
||||
longa off
|
||||
inc <L18+alone_1
|
||||
rep #$20
|
||||
longa on
|
||||
lda #$0
|
||||
dey
|
||||
dey
|
||||
sta (<L18+next_1),Y
|
||||
lda <L18+next_1
|
||||
sta |__events
|
||||
bra L10007
|
||||
L10008:
|
||||
ldy #$4
|
||||
lda (<L17+eventElement_0),Y
|
||||
beq L10007
|
||||
sep #$20
|
||||
longa off
|
||||
inc <L18+alone_1
|
||||
rep #$20
|
||||
longa on
|
||||
lda #$0
|
||||
L20007:
|
||||
ldy #$6
|
||||
sta (<L18+previous_1),Y
|
||||
L10007:
|
||||
pei <L17+eventElement_0
|
||||
jsr __free
|
||||
lda <L18+alone_1
|
||||
and #$ff
|
||||
bne L24
|
||||
stz |__events
|
||||
L24:
|
||||
lda <L17+1
|
||||
sta <L17+1+2
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L17+2
|
||||
tcs
|
||||
rts
|
||||
L17 equ 5
|
||||
L18 equ 1
|
||||
ends
|
||||
efunc
|
||||
code
|
||||
xdef __processEvents
|
||||
func
|
||||
__processEvents:
|
||||
longa on
|
||||
longi on
|
||||
tsc
|
||||
sec
|
||||
sbc #L25
|
||||
tcs
|
||||
phd
|
||||
tcd
|
||||
currentEvent_1 set 0
|
||||
returnValue_1 set 2
|
||||
lda |__events
|
||||
L20008:
|
||||
sta <L26+currentEvent_1
|
||||
lda <L26+currentEvent_1
|
||||
bne L20010
|
||||
pld
|
||||
tsc
|
||||
clc
|
||||
adc #L25
|
||||
tcs
|
||||
rts
|
||||
L20010:
|
||||
lda (<L26+currentEvent_1)
|
||||
pha
|
||||
ldy #$2
|
||||
lda (<L26+currentEvent_1),Y
|
||||
xref __~cal
|
||||
jsr __~cal
|
||||
sep #$20
|
||||
longa off
|
||||
sta <L26+returnValue_1
|
||||
cmp #<$1
|
||||
rep #$20
|
||||
longa on
|
||||
bne L10014
|
||||
lda (<L26+currentEvent_1)
|
||||
ina
|
||||
sta (<L26+currentEvent_1)
|
||||
bra L10015
|
||||
L10014:
|
||||
pei <L26+currentEvent_1
|
||||
jsr __removeEvent
|
||||
L10015:
|
||||
ldy #$6
|
||||
lda (<L26+currentEvent_1),Y
|
||||
bra L20008
|
||||
L25 equ 3
|
||||
L26 equ 1
|
||||
ends
|
||||
efunc
|
||||
xref __malloc
|
||||
xref __free
|
||||
udata
|
||||
xdef __events
|
||||
__events
|
||||
ds 2
|
||||
ends
|
||||
@@ -0,0 +1,101 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "data.h";
|
||||
#include "event.h";
|
||||
|
||||
event *events;
|
||||
|
||||
void initEvents(void) {
|
||||
events = NULL;
|
||||
}
|
||||
|
||||
event *createEvent(char (*callback)(word counter)) {
|
||||
event *myEvent;
|
||||
|
||||
myEvent = (event*) malloc(sizeof(event));
|
||||
|
||||
myEvent->VBlankCount = 0;
|
||||
myEvent->callback = callback;
|
||||
myEvent->nextEvent = NULL;
|
||||
myEvent->previousEvent = NULL;
|
||||
|
||||
|
||||
return myEvent;
|
||||
}
|
||||
|
||||
event* addEvent(char (*callback)(word counter), int noDuplicateCallback) {
|
||||
|
||||
event *lastEvent;
|
||||
event *myEvent;
|
||||
|
||||
if(events == NULL) {
|
||||
events = createEvent(callback);
|
||||
return events;
|
||||
} else {
|
||||
lastEvent = events;
|
||||
// TODO optimise this with noduplicate
|
||||
while(lastEvent->nextEvent != NULL) {
|
||||
if(noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
||||
return NULL;
|
||||
}
|
||||
lastEvent = lastEvent->nextEvent;
|
||||
}
|
||||
if(noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
||||
return NULL;
|
||||
}
|
||||
myEvent = createEvent(callback);
|
||||
myEvent->previousEvent = lastEvent;
|
||||
lastEvent->nextEvent = myEvent;
|
||||
return myEvent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void removeEvent(event *eventElement) {
|
||||
|
||||
byte alone = 0;
|
||||
event *next, *previous;
|
||||
|
||||
next = eventElement->nextEvent;
|
||||
previous = eventElement->previousEvent;
|
||||
|
||||
if(eventElement->nextEvent != NULL && eventElement->previousEvent != NULL) {
|
||||
alone++;
|
||||
next->previousEvent = previous;
|
||||
previous->nextEvent = next;
|
||||
|
||||
} else if(eventElement->nextEvent != NULL) {
|
||||
alone++;
|
||||
next->previousEvent = NULL;
|
||||
events = next;
|
||||
|
||||
} else if(eventElement->previousEvent != NULL) {
|
||||
alone++;
|
||||
previous->nextEvent = NULL;
|
||||
}
|
||||
|
||||
free(eventElement);
|
||||
|
||||
if(alone == 0) {
|
||||
events = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void processEvents(void) {
|
||||
|
||||
event *currentEvent;
|
||||
char returnValue;
|
||||
|
||||
currentEvent = events;
|
||||
while(currentEvent != NULL) {
|
||||
returnValue = currentEvent->callback(currentEvent->VBlankCount);
|
||||
if(returnValue == EVENT_CONTINUE) {
|
||||
currentEvent->VBlankCount++;
|
||||
} else {
|
||||
removeEvent(currentEvent);
|
||||
}
|
||||
currentEvent = currentEvent->nextEvent;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
typedef struct event{
|
||||
word VBlankCount;
|
||||
char (*callback)(word counter);
|
||||
struct event *previousEvent;
|
||||
struct event *nextEvent;
|
||||
} event;
|
||||
|
||||
#define EVENT_STOP 0
|
||||
#define EVENT_CONTINUE 1
|
||||
|
||||
extern event *events;
|
||||
|
||||
void initEvents(void);
|
||||
extern event* addEvent(char (*callback)(word counter), int noDuplicateCallback);
|
||||
extern void removeEvent(event *eventElement);
|
||||
extern void processEvents(void);
|
||||
@@ -0,0 +1,71 @@
|
||||
#include "data.h";
|
||||
#include "pad.h";
|
||||
#include "event.h";
|
||||
#include "myEvents.h";
|
||||
#include "ressource.h";
|
||||
#include "PPU.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
padStatus pad1;
|
||||
|
||||
event *currentScrollEvent;
|
||||
word scrollValue;
|
||||
|
||||
void initInternalRegisters(void) {
|
||||
characterLocation[0] = 0x0000;
|
||||
characterLocation[1] = 0x0000;
|
||||
characterLocation[2] = 0x0000;
|
||||
characterLocation[3] = 0x0000;
|
||||
|
||||
initDebugMap();
|
||||
}
|
||||
|
||||
void preInit(void) {
|
||||
// For testing purpose ...
|
||||
// Insert code here to be executed before register init
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
|
||||
initInternalRegisters();
|
||||
|
||||
// Screen map data @ VRAM location $1000
|
||||
setTileMapLocation(0x1000, (byte) 0x00, (byte) 0);
|
||||
//*(byte*) 0x2107 = 0x10;
|
||||
|
||||
// Plane 0 Tile graphics @ $2000
|
||||
setCharacterLocation(0x2000, (byte) 0);
|
||||
//*(byte*) 0x210b = 0x02;
|
||||
|
||||
//VRAMLoad((word) title_pic, 0x2000, 0x1BE0);
|
||||
//VRAMLoad((word) title_map, 0x1000, 0x0800);
|
||||
CGRAMLoad((word) title_pal, (byte) 0x00, (word) 256);
|
||||
|
||||
// TODO sitwch to mode 0 for trying
|
||||
*(byte*) 0x2105 = 0x01; // MODE 1 value
|
||||
|
||||
*(byte*) 0x212c = 0x01; // Plane 0 (bit one) enable register
|
||||
*(byte*) 0x212d = 0x00; // All subPlane disable
|
||||
|
||||
*(byte*) 0x2100 = 0x0f; // enable background
|
||||
|
||||
currentScrollEvent = NULL;
|
||||
scrollValue = 0;
|
||||
|
||||
//initEvents();
|
||||
//enablePad();
|
||||
debug();
|
||||
//addEvent(&NMIReadPad, 1);
|
||||
|
||||
// Loop forever
|
||||
while(1);
|
||||
}
|
||||
|
||||
void IRQHandler(void) {
|
||||
}
|
||||
|
||||
void NMIHandler(void) {
|
||||
//processEvents();
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
#include "data.h";
|
||||
#include "pad.h";
|
||||
#include "event.h";
|
||||
|
||||
extern padStatus pad1;
|
||||
extern word scrollValue;
|
||||
|
||||
char fadeOut(word counter) {
|
||||
static byte fadeOutValue;
|
||||
|
||||
if(counter == 0) {
|
||||
// init fade value
|
||||
fadeOutValue = 0x0f;
|
||||
} else {
|
||||
fadeOutValue--;
|
||||
}
|
||||
|
||||
*(byte*) 0x2100 = fadeOutValue;
|
||||
|
||||
if(fadeOutValue == 0x00) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
char fadeIn(word counter) {
|
||||
static byte fadeInValue;
|
||||
|
||||
if(counter == 0) {
|
||||
// init fade value
|
||||
fadeInValue = 0x00;
|
||||
} else {
|
||||
fadeInValue++;
|
||||
}
|
||||
|
||||
*(byte*) 0x2100 = fadeInValue;
|
||||
|
||||
if(fadeInValue >= 0x0f) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
char mosaicOut(word counter) {
|
||||
static byte mosaicOutValue;
|
||||
|
||||
if(counter == 0) {
|
||||
// init fade value
|
||||
mosaicOutValue = 0xff;
|
||||
} else {
|
||||
mosaicOutValue -= 0x10;
|
||||
}
|
||||
|
||||
*(byte*) 0x2106 = mosaicOutValue;
|
||||
|
||||
if(mosaicOutValue == 0x0f) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
char mosaicIn(word counter) {
|
||||
static byte mosaicInValue;
|
||||
|
||||
if(counter == 0) {
|
||||
// init fade value
|
||||
mosaicInValue = 0x0f;
|
||||
} else {
|
||||
mosaicInValue += 0x10;
|
||||
}
|
||||
|
||||
*(byte*) 0x2106 = mosaicInValue;
|
||||
|
||||
if(mosaicInValue == 0xff) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
char NMIReadPad(word counter) {
|
||||
pad1 = readPad((byte) 0);
|
||||
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
|
||||
char scrollLeft(word counter) {
|
||||
scrollValue++;
|
||||
|
||||
*(byte*) 0x210d = (byte) scrollValue;
|
||||
*(byte*) 0x210d = (byte) (scrollValue>>8);
|
||||
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
char fadeOut(word counter);
|
||||
char fadeIn(word counter);
|
||||
char mosaicOut(word counter);
|
||||
char mosaicIn(word counter);
|
||||
char NMIReadPad(word counter);
|
||||
char scrollLeft(word counter);
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "data.h";
|
||||
#include "pad.h";
|
||||
|
||||
void enablePad(void) {
|
||||
// Enable pad reading and NMI
|
||||
*(byte*)0x4200 = 0x81;
|
||||
}
|
||||
|
||||
padStatus readPad(byte padNumber) {
|
||||
word test;
|
||||
padStatus *status;
|
||||
padNumber = padNumber << 1;
|
||||
test = (word) *(byte*)0x4218+padNumber << 8;
|
||||
test |= (word) *(byte*)0x4219+padNumber;
|
||||
status = (padStatus *) &test;
|
||||
return *status;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
typedef struct padStatus{
|
||||
byte right:1;
|
||||
byte left:1;
|
||||
byte down:1;
|
||||
byte up:1;
|
||||
byte start:1; // Enter
|
||||
byte select:1; // Space
|
||||
byte Y:1; // X
|
||||
byte B:1; // C
|
||||
//--------------------------------
|
||||
byte Dummy:4;
|
||||
byte R:1; // Z
|
||||
byte L:1; // A
|
||||
byte X:1; // S
|
||||
byte A:1; // D
|
||||
} padStatus;
|
||||
|
||||
extern void enablePad(void);
|
||||
extern padStatus readPad(byte padNumber);
|
||||
@@ -0,0 +1,23 @@
|
||||
ressource .section
|
||||
|
||||
; XDEF __title_map
|
||||
;__title_map:
|
||||
; INSERT ressource/kungfu.map
|
||||
;
|
||||
; XDEF __title_pic
|
||||
;__title_pic:
|
||||
; INSERT ressource/kungfu.pic
|
||||
;
|
||||
XDEF __title_pal
|
||||
__title_pal:
|
||||
INSERT ressource/kungfu.clr
|
||||
|
||||
XDEF __debugFont_pic
|
||||
__debugFont_pic
|
||||
INSERT ressource/debugFont.pic
|
||||
|
||||
XDEF __debugFont_pal
|
||||
__debugFont_pal
|
||||
INSERT ressource/debugFont.clr
|
||||
|
||||
.ends
|
||||
@@ -0,0 +1,6 @@
|
||||
//extern word title_map[];
|
||||
//extern word title_pic[];
|
||||
extern word title_pal[];
|
||||
|
||||
extern word debugFont_pic[];
|
||||
extern word debugFont_pal[];
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
wine $*
|
||||
exit 0
|
||||
Reference in New Issue
Block a user