optixx 14 years ago
parent
commit
5b6e62a428
48 changed files with 0 additions and 19991 deletions
  1. 0 36
      snes/loader/conv_rle.py
  2. 0 61
      snes/loader/data/apu/amigaperiodtable.tbl
  3. 0 3326
      snes/loader/data/apu/apucode.asm
  4. BIN
      snes/loader/data/apu/pitchtable2.tbl
  5. 0 860
      snes/loader/data/apu/pitchtable_new.tbl
  6. BIN
      snes/loader/data/apu/vibratotable.tbl
  7. BIN
      snes/loader/data/battle_sky.clr
  8. BIN
      snes/loader/data/blanktile.pic
  9. BIN
      snes/loader/data/cpuusage.clr
  10. BIN
      snes/loader/data/cpuusage.pic
  11. 0 1
      snes/loader/data/font/asciitablejap.tbl
  12. BIN
      snes/loader/data/font/font1.pic
  13. BIN
      snes/loader/data/font/font1pal.clr
  14. BIN
      snes/loader/data/sounds/hit.brr
  15. 0 2
      snes/loader/linkfile
  16. 0 310
      snes/loader/main.asm
  17. 0 50
      snes/loader/makefile
  18. 0 4
      snes/loader/routines/audiostreams.asm
  19. 0 22
      snes/loader/routines/backgroundfiles.asm
  20. 0 272
      snes/loader/routines/bgmodes.asm
  21. 0 255
      snes/loader/routines/defines.asm
  22. 0 975
      snes/loader/routines/dmafifo.asm
  23. 0 90
      snes/loader/routines/eventroutines.asm
  24. 0 662
      snes/loader/routines/gfxvrammisc.asm
  25. 0 362
      snes/loader/routines/irq.asm
  26. 0 126
      snes/loader/routines/joypadread.asm
  27. 0 1128
      snes/loader/routines/levelfiles.asm
  28. 0 160
      snes/loader/routines/memoryclear.asm
  29. 0 320
      snes/loader/routines/menufiles.asm
  30. 0 174
      snes/loader/routines/menusubroutines.asm
  31. 0 706
      snes/loader/routines/menusystem.asm
  32. 0 530
      snes/loader/routines/miscdata.asm
  33. 0 1045
      snes/loader/routines/oamanimationlists.asm
  34. 0 3092
      snes/loader/routines/oammanager.asm
  35. 0 94
      snes/loader/routines/oamobjects.asm
  36. 0 20
      snes/loader/routines/oamsubroutines.asm
  37. 0 2054
      snes/loader/routines/oamvectoranglelut.asm
  38. 0 756
      snes/loader/routines/printstring.asm
  39. 0 40
      snes/loader/routines/randomnumbergen.asm
  40. 0 34
      snes/loader/routines/samplepacks.asm
  41. 0 74
      snes/loader/routines/sinetables.asm
  42. 0 16
      snes/loader/routines/songs.asm
  43. 0 1152
      snes/loader/routines/spcinterface.asm
  44. 0 28
      snes/loader/routines/spritedata.asm
  45. 0 648
      snes/loader/routines/textstrings.asm
  46. 0 328
      snes/loader/routines/variables.asm
  47. 0 176
      snes/loader/routines/vblanknmi.asm
  48. 0 2
      snes/loader/spclinkfile

+ 0 - 36
snes/loader/conv_rle.py

@@ -1,36 +0,0 @@
-import binascii
-data = open("rom.smc","r").read()
-data = binascii.rlecode_hqx(data)
-
-cfile = open("loader.c","w")
-hfile = open("loader.h","w")
-
-hfile.write('''
-#ifndef __FIFO_H__
-#define __FIFO_H__
-
-#define ROM_SIZE %i
-
-#endif
-''' % len(data))
-
-cfile.write('''
-
-#include <avr/pgmspace.h>       
-#include <loader.h>       
-
-const char _rom[ROM_SIZE] PROGMEM = {
-''')
-
-for idx,c in enumerate(data):
-    c = ord(c)
-    if idx<len(data)-1:
-        cfile.write("0x%02x," % c)
-    else:
-        cfile.write("0x%02x" % c)
-    if idx and idx%16==0:
-        cfile.write("\n")
-cfile.write('''
-};
-''')
-cfile.close()

+ 0 - 61
snes/loader/data/apu/amigaperiodtable.tbl

@@ -1,61 +0,0 @@
-;this table contains the corresponding amiga periods for the note values in the modfile
-.dw $0358
-.dw $0328
-.dw $02FA
-.dw $02D0
-.dw $02A6
-.dw $0280
-.dw $025C
-.dw $023A
-.dw $021A
-.dw $01FC
-.dw $01E0
-.dw $01C5
-.dw $01AC
-.dw $0194
-.dw $017D
-.dw $0168
-.dw $0153
-.dw $0140
-.dw $012E
-.dw $011D
-.dw $010D
-.dw $00FE
-.dw $00F0
-.dw $00E2
-.dw $00D6
-.dw $00CA
-.dw $00BE
-.dw $00B4
-.dw $00AA
-.dw $00A0
-.dw $0097
-.dw $008F
-.dw $0087
-.dw $007F
-.dw $0078
-.dw $0071
-.dw $006B
-.dw $0065
-.dw $005F
-.dw $005A
-.dw $0055
-.dw $0050
-.dw $004B
-.dw $0047
-.dw $0043
-.dw $003F
-.dw $003C
-.dw $0038
-.dw $0035
-.dw $0032
-.dw $002F
-.dw $002D
-.dw $002A
-.dw $0028
-.dw $0025
-.dw $0023
-.dw $0021
-.dw $001F
-.dw $001e
-.dw $001c

+ 0 - 3326
snes/loader/data/apu/apucode.asm

@@ -1,3326 +0,0 @@
-;----------------------------------------------------------------------------------------
-;pro tracker (mod) player for the spc700 (c)d4s in 2005
-;----------------------------------------------------------------------------------------
-
-.MEMORYMAP					; Tell WLA that the SPC has RAM at locations ;$0000-$ffff in every bank
-SLOTSIZE $10000			; and that this area is $10000 bytes in size.
-DEFAULTSLOT 0				; There is only a single slot in SNES, other consoles
-SLOT 0 $0000				; may have more slots per bank.
-.ENDME
-
-.ROMBANKSIZE $10000		; Every ROM bank is 64 KBytes in size
-.ROMBANKS 1
-;----------------------------------------------------------------------------------------
-.BANK 0 SLOT 0
-
-
-
-.define SpcCmdUploadSong	$f1		;indicates that a song is to be uploaded
-.define SpcCmdUploadSongT1	$f2		;indicates that data for transfer1 is on apu ports
-.define SpcCmdUploadSongT2	$f3		;indicates that data for transfer2 is on apu ports
-.define SpcCmdUploadSongDone	$f4		;indicates that song upload is complete
-.define SpcCmdReceiveStream	$f5		;indicates that 65816 wants to stream brr data to spc
-.define SpcCmdSubmitStreamNumber	$f7		;indicates that 65816 wants to stream brr data to spc
-.define SpcCmdReceiveStreamComplete	$f6	;spc wants to end stream transmission
-.define SpcCmdUploadSamplePack	$f8		;indicates that a sample pack is to be uploaded. the rest of the commands are taken from normal song upload
-.define SpcCmdUploadSamplePackDone	$f9		;indicates that sample pack upload is complete
-.define SpcCmdPlaySoundEffect	$fa		;play a sound effect
-.define SpcCmdStopSong		$fb
-.define SpcCmdSetSongSpeed	$fc		;set timer speed of mod playback routine
-.define SpcCmdSetSongChMask	$fd		;song channel mask
-.define SpcCmdReportType	$fe		;type of data spc should respond with
-.define SpcCmdSetSongVolume	$ff
-
-.define SpcStreamLatency	7		;number of frames to load before actually playing sample
-.define SpcStreamSampleNumber	33		;number of dsp sample to use as streamer
-.define StreamerTimer0		$00		;how long to wait before downloading next frame
-
-.define ChannelArray		$0
-.define ExtSample		$20		;this sample is used for set sample offset effect
-
-.define Stack			$ff
-.define ApuCodeBaseAdress	$300
-.define SampleSource		$0200		;$ff bytes long
-.define StreamBuffer		$fb80		;480 bytes long
-.define HighestPortaPeriod	$0071
-.define LowestPortaPeriod	$0358
-.define EchoStartAdress		$f8
-.define EchoDelay		$01
-
-.define SongEffectsUploaded	$ef			;flags that indicate whether a song or sample pack have already been uploaded.bit0=song bit1=sample pack. wla is too stupid to recognize a variable here, so we have to use a static one.
-;variables:
-;.........................................................
-.enum $60
-WaitCounter		dw
-CurrentPatternPointerLo	db
-CurrentPatternPointerHi	db
-InitPatternPointerLo	db
-InitPatternPointerHi	db
-PortamentoDownLimitLo	db
-PortamentoDownLimitHi	db
-PortamentoUpLimitLo	db
-PortamentoUpLimitHi	db
-CurrentChDataLo		db
-CurrentChDataHi		db
-TempBuffer1		db
-TempBuffer2		db
-TempBuffer3		db
-TempBuffer4		db
-
-TempBuffer5		db
-TempBuffer6		db
-TempBuffer7		db
-TempBuffer8		db
-TempBuffer9		db
-TempBuffer10		db
-TempVol			db
-KeyOn			db
-CurrentChannel		db
-CurrentVolume		db
-PitchBufferLo		db
-PitchBufferHi		db
-CurrentPatternNumber	db
-PortamentoSpeedMask	db
-NotUsedVariable		db
-CurrentPeriodPointer	db
-CurrentPeriodPointerHi	db
-
-PeriodTablePointerLo	db
-PeriodTablePointerHi	db
-SpcDataPointerLo	db
-SpcDataPointerHi	db
-ModFilePointerLo	db
-ModFilePointerHi	db
-ModFilePointer2Lo	db
-ModFilePointer2Hi	db
-
-;added variables
-
-ScratchPad1		db
-ScratchPad2		db
-ScratchPad3		db
-
-PeriodBufferLo		db
-PeriodBufferHi		db
-
-NumberOfPatterns	db
-PatternSpeed		db
-NextRowChFadeOuts	db		;lower nibble bits0-4:channels to fade out for next row
-NextRowChFadeOutTime	db		;patternspeed-2
-PortamentoLUTLo		db	;table for portamento up/down
-PortamentoLUTHi		db	;table for portamento up/down
-TonePortamentoLUTLo	db	;table for portamento up/down
-TonePortamentoLUTHi	db	;table for portamento up/down
-CurrentRowPointerLo	db
-CurrentRowPointerHi	db
-CurrentLoopPointerLo	db
-CurrentLoopPointerHi	db
-LoopCounter		db
-PatternBreakFlag	db	;if bit0 is set, break to next pattern
-
-;main volume section:
-MainVolL		db
-MainVolR		db
-EchoVolL		db
-EchoVolR		db
-ChannelEnable		db
-ChannelEchoEnable	db
-
-
-PitchTablePointerLo	db
-PitchTablePointerHi	db
-
-Channel1Array		dw
-Channel2Array		dw
-Channel3Array		dw
-Channel4Array		dw
-
-;apu streaming stuff
-StreamState		db			;variable for streaming state machine
-StreamCurrentBuffer	db			;indicates currently active stream buffer out of 8
-StreamVolume		db
-
-ActiveSoundEffectCh	db			;0-3
-ModPlayerTimer0		db
-SongChannelMask		db			;mask variable for 4 song channels. default $0f
-SpcReportType		db
-ModTimecode		dw			;timecode for mod currently playing. reset after song upload
-SpecialReportCmd	db
-SoundEffectFlipFlag	db
-TickSampleStart		db		;channel mask	to start samples on the next tick. used for delay and retrigger
-MusicVol1			db		;mod channel 0,2 volume
-MusicVol2			db		;mod channel 1,3 volume
-.ende
-
-
-;channel variables
-.enum			$00
-ch_instrument			db		;00
-ch_note				db		;01
-ch_effect			db		;02
-ch_effect_data			db		;03
-ch_finetune			db		;04
-ch_current_volume		db		;05
-ch_current_pitch_lo		db		;06 this gets updated on portamento etc
-ch_current_pitch_hi		db		;07 (not directly used in sourcecode)
-ch_target_pitch_lo		db		;08 (not used at all in sourcecode) target pitch for tone portamento
-ch_target_pitch_hi		db		;09 (not used at all in sourcecode)
-ch_tone_portamento_speed	db		;0a
-ch_portamento_slide_dir		db		;0b bit0 sets up/down
-ch_vibrato_command_buffer	db		;0c this is a buffer for depth and speed when using vibrato continue
-ch_vibrato_position		db		;0d
-ch_vibrato_tremolo_waveform	db		;0e 0=sine, 1=ramp down, 2=square
-ch_tremolo_position		db		;0f
-ch_tremolo_command_buffer	db		;10
-ch_arpeggio_note_buffer		db		;11
-ch_tick_delay			db		;12
-ch_amiga_period_lo		db		;13 this is the current amiga period
-ch_amiga_period_hi		db		;14 (not directly used in sourcecode)
-ch_current_amiga_period_lo	db		;15 this is the tone portamento target amiga period
-ch_current_amiga_period_hi	db		;16 (not directly used in sourcecode)
-;next must be the last entry in this array:
-ch_current_channelmask		db		;last byte in array and mask for channel
-
-
-
-.ende
-
-
-;.........................................................
-
-
-
-.ORGA (ApuCodeBaseAdress-2)		;$2FC
-.DW ApuCodeBaseAdress			;spcram copy offset
-
-
-
-
-BootInit:
-	clrp
-	mov	$f1,#$f0
-	mov	a,#$ff
-	mov	!$fff0,a
-	mov	x,#Stack			;set stack pointer (old: $cf)
-	mov	sp,x
-	mov	a,#$00
-	mov	x,a
-	jmp	!ClearVariables
-
-CopyRight:
-	.db "matt@dforce3000.de"
-CopyRightEnd:
-
-ClearVariables:
-	mov	(x)+,a
-	cmp	x,#$f0
-	bne	ClearVariables
-
-	mov MainVolL,#$7f
-	mov MainVolR,#$7f
-	mov EchoVolL,#$00
-	mov EchoVolR,#$00
-	mov ChannelEnable,#$0f
-	mov ChannelEchoEnable,#$0f
-	mov SpcReportType,#0		;reset report type to void
-	mov	MusicVol1,#$7f			;init volume. narrow stereo, a little bit stereo separation
-	mov	MusicVol2,#$7f
-
-	
-	mov	SpcDataPointerLo,#(ModFile & $00ff)		;setup mod pointer
-	mov	SpcDataPointerHi,#(ModFile >> 8)
-
-	call	!ClearAllChannelArray
-	call	!SetupDspRegsAndTimers		;reset dsp regs first.
-	call	!InitVariables		;set up pointers to first pattern
-	call	!UpdateVolEchoVariablesOnly
-	
-
-MainLoop:
-	mov	a,$fd		;clear counter0
-MainLoop1:
-	mov	a,$fd		;wait for counter 0 to become zero
-	beq	MainLoop1		;takes roughly 44 scanlines total
-
-	call	!MainWaitLoop		
-	call	!SendReportData
-
-	mov	a,$f4		;check if command present on port0
-	and	a,#$f0
-	cmp	a,#$f0
-	bne	MainLoop	;return to mainloop if there isn't
-
-	mov	a,$f4		;get command
-	and	a,#$0f	
-	asl 	a
-	mov	x,a			;pointer into jump table
-	jmp	[!CommandJumpTable+x]
-	
-CommandJumpTable:
-	.dw CommandVoid			;0
-	.dw ReceiveSong
-	.dw CommandVoid
-	.dw CommandVoid
-	.dw CommandVoid
-	.dw ReceiveStream		;5
-	.dw CommandVoid
-	.dw CommandVoid
-	.dw ReceiveSamplePack
-	.dw CommandVoid
-	.dw PlaySoundEffect		;10
-	.dw StopSongStream
-	.dw SetSongSpeed
-	.dw SetSongChannelMask
-	.dw SetReportType
-	.dw SetSongVolume
-
-
-ReceiveSong:
-	 ;timers must be reset before receiving a song, else we can't wait properly for the echo buffer to initialize
-	call	!ReceiveSongHandler
-	call	!ClearAllChannelArray
-	call	!SetupSamples		;set up sample offsets
-	call	!SetupDspRegsAndTimers		;reset dsp regs first.
-	call	!InitVariables		;set up pointers to first pattern
-	call	!UpdateVolEchoVariablesOnly
-;return to mainloop:
-	bra MainLoop
-
-UpdateVolEcho:
-	call	!UpdateVolEchoHandler
-	bra	MainLoop
-
-ResetHandler:
-;clear apu ports:
-	mov	y,#$00
-	mov	$f4,y
-	mov	$f5,y
-	mov	$f6,y
-	mov	$f7,y
-;clear dsp regs:
-	mov	a,#$6c
-	mov	y,#$e0		;reset dsp, mute on, echo off
-	movw	$f2,ya
-	mov	a,#$0c
-	movw	$f2,ya
-	mov	a,#$1c
-	movw	$f2,ya
-	mov	a,#$2c
-	movw	$f2,ya
-	mov	a,#$3c
-	movw	$f2,ya
-	mov	a,#$4c
-	movw	$f2,ya
-	mov	y,#$ff
-	mov	a,#$5c
-	movw	$f2,ya
-	mov	y,#$00
-	mov	a,#$0d
-	movw	$f2,ya
-	mov	a,#$2d
-	movw	$f2,ya
-	mov	a,#$3d
-	movw	$f2,ya
-	mov	a,#$4d
-	movw	$f2,ya
-	mov	a,#$5d
-	movw	$f2,ya
-	mov	a,#$6d
-	movw	$f2,ya
-	mov	a,#$7d
-	movw	$f2,ya
-	mov	$f1,#$f0
-;jump to ipl rom:
-	jmp	!$ffc0
-	jmp	!$ffc0
-
-MainWaitLoop:
-	bbs	$ef.0,MainWaitLoopSongPresent		;only process song if song has been uploaded before
-	ret
-	
-MainWaitLoopSongPresent:
-	inc	WaitCounter
-
-InnerWaitLoop:
-	cmp	WaitCounter,PatternSpeed			;old #$04 incremet WaitCounter until 4, selfmodying code changes the default speed(command setspeed0x0f) by writing to the second operand
-	bne	UpdateTickBasedEffectsOnly
-
-
-	mov	WaitCounter,#$00
-	mov	y,NextRowChFadeOuts
-	mov	a,#$5c
-	movw	$f2,ya
-	mov	a,$fe	;clear 4bit counter
-	mov	y,#2
-KofWaitLoop:
-	mov	a,$fe		;wait for 2mS
-	beq	KofWaitLoop
-;**************************************************
-	dbnz	y,KofWaitLoop
-
-	call	 !ProcessNextRow
-
-	call	!PreTestRow
-	ret
-
-
-
-UpdateTickBasedEffectsOnly:	
-
-
-	movw	ya,Channel1Array
-	movw	CurrentChDataLo,ya
-	mov	CurrentChannel,#$00
-	call	!CheckForTickBasedEffects
-	movw	ya,Channel2Array
-	movw	CurrentChDataLo,ya
-	mov	CurrentChannel,#$10
-	call	!CheckForTickBasedEffects
-	movw	ya,Channel3Array
-	movw	CurrentChDataLo,ya
-	mov	CurrentChannel,#$20
-	call	!CheckForTickBasedEffects
-
-	movw	ya,Channel4Array
-	movw	CurrentChDataLo,ya	
-	mov	CurrentChannel,#$30
-	call	!CheckForTickBasedEffects
-
-	mov	a,TickSampleStart
-	beq UpdateTickBasedEffectsOnlyNoRetrigger
-
-	mov	$f2,#$4c			
-	mov	$f3,a							;retrigger recently started samples
-	
-	mov	TickSampleStart,#0
-UpdateTickBasedEffectsOnlyNoRetrigger:
-
-	ret
-
-
-
-ProcessNextRow:
-	movw	ya,CurrentPatternPointerLo	;mark beginning of current row
-	movw	CurrentRowPointerLo,ya
-
-	incw	ModTimecode
-	mov	KeyOn,#$00			;clear key on
-	movw	ya,Channel1Array
-	movw	CurrentChDataLo,ya	
-	mov	CurrentChannel,#$00
-	call	!GetDataFromPattern
-	call	!SetVolume
-	movw	ya,Channel2Array
-	movw	CurrentChDataLo,ya	
-	mov	CurrentChannel,#$10
-	call	!GetDataFromPattern
-	call	!SetVolume
-	movw	ya,Channel3Array
-	movw	CurrentChDataLo,ya	
-	mov	CurrentChannel,#$20
-	call	!GetDataFromPattern
-	call	!SetVolume
-	movw	ya,Channel4Array
-	movw	CurrentChDataLo,ya	
-	mov	CurrentChannel,#$30
-	call	!GetDataFromPattern
-	call	!SetVolume
-	
-	call	!KeyOnKeyOff
-	call	!PatternLoopJumper
-	jmp	!GetDataFromPatternCheckPatternPosition
-
-
-GetDataFromPatternEntryIsVoid:
-	incw	CurrentPatternPointerLo
-	mov	y,#ch_instrument
-	mov	a,#$ff					;store $ff in all 4 channel input buffers
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	[CurrentChDataLo]+y,a
-	ret
-
-
-
-GetDataFromPattern:
-	mov	y,#ch_instrument
-	mov	a,[CurrentChDataLo]+y			;get last rows instrument, pitch and effects
-	mov	TempBuffer1,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer5,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer6,a
-	or	 TempBuffer1,TempBuffer2
-	or	 TempBuffer1,TempBuffer5
-	or	 TempBuffer1,TempBuffer6			;check if a note was present
-	mov	a,TempBuffer1
-	bne	GetDataFromPatternEntryContainsNewData
-	call	!GetPitchFromBufferAndSet
-
-GetDataFromPatternEntryContainsNewData:
-	mov	y,#$00
-	mov	a,[CurrentPatternPointerLo]+y
-	cmp	a,#$ff			;compare if channel entry is $ff(skip)
-	beq	GetDataFromPatternEntryIsVoid
-
-;there is a new note to trigger, copy data from pattern to current channel data buffer:
-	
-	mov	[CurrentChDataLo]+y,a	;copy instrument
-	inc	y
-	mov	a,[CurrentPatternPointerLo]+y			;copy note
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,[CurrentPatternPointerLo]+y			;copy effect
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,[CurrentPatternPointerLo]+y			;copy effect data
-	mov	[CurrentChDataLo]+y,a
-	incw	CurrentPatternPointerLo
-	incw	CurrentPatternPointerLo
-	incw	CurrentPatternPointerLo
-	incw	CurrentPatternPointerLo
-
-
-	mov	y,#ch_effect
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	mov	TempBuffer1,a
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$f0
-	or	a,TempBuffer1
-	cmp	a,#$de					;delay sample effect present? if yes, don't trigger sample
-	beq DontSetNewSample
-	
-	call	!SetNewSample
-	
-DontSetNewSample:
-	ret
-	
-SetNewSample:		
-	mov	y,#ch_instrument						;a non-present instrument is indicated by $00
-	mov	a,[CurrentChDataLo]+y
-	beq	GetDataFromPatternInstrumentIsVoid
-
-;trigger new instrument, fetch sample data for current instrument
-	dec	a							;multiply instrument number with 8 to get pointer into sample array
-	mov	y,#$08
-	mul	ya
-	addw	ya,ModFilePointer2Lo				
-	movw	TempBuffer1,ya					;tempbuffer1 is now pointer to current sample entry
-	mov	y,#$02						;get sample finetune
-	mov	a,[TempBuffer1]+y
-	mov	y,#ch_finetune						;save to current channel finetune
-	mov	[CurrentChDataLo]+y,a				
-	mov	y,#$03						;get sample volume
-	mov	a,[TempBuffer1]+y
-	mov	CurrentVolume,a					;save to current volume and current channel volume
-	mov	y,#ch_current_volume
-	mov	[CurrentChDataLo]+y,a
-
-GetDataFromPatternInstrumentIsVoid:
-	mov	y,#ch_note
-	mov	a,[CurrentChDataLo]+y
-	cmp	a,#$ff					;a non-present note is indicated by $ff
-	beq	GetDataFromPatternPeriodIsVoid
-
-	mov	y,#ch_effect					;check if effect command is $ff
-	mov	a,[CurrentChDataLo]+y
-	cmp	a,#$ff
-	beq	GetDataFromPatternCalculateNewPeriod	;if it is, directly calculate new period (why?)
-
-	and	a,#$0f					;merge effect command and data to test for finetune command
-	mov	TempBuffer1,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$f0
-	or	 a,TempBuffer1
-	xcn	a
-
-	cmp	a,#$e5			;finetune
-	beq	FinetuneStep
-
-	mov	y,#ch_effect
-	mov	a,[CurrentChDataLo]+y			;get current effect
-	and	a,#$0f
-	cmp	a,#$03					;check if effect is tone portamento
-	beq	GetDataFromPatternPortamento
-
-	cmp	a,#$05					;check if effect is tone portamento and volslide
-	beq	GetDataFromPatternPortamento
-	bra	GetDataFromPatternCalculateNewPeriod
-
-FinetuneStep:
-	call	!Finetune
-	bra	GetDataFromPatternCalculateNewPeriod
-
-GetDataFromPatternPortamento:
-	call	!TonePortamento
-	
-	jmp	!GetDataFromPatternCheckEffects
-
-
-GetDataFromPatternPeriodIsVoid:
-	jmp	!GetDataFromPatternCheckEffects
-
-GetDataFromPatternCalculateNewPeriod:
-	mov	y,#ch_note
-	mov	a,[CurrentChDataLo]+y
-	mov	y,#ch_arpeggio_note_buffer
-	mov	[CurrentChDataLo]+y,a
-	mov	y,a				;put period in y
-	push	y
-	mov	y,#ch_finetune				
-	mov	a,[CurrentChDataLo]+y		;calculate finetune
-	mov	y,#$48
-	mul	ya
-	addw	ya,PeriodTablePointerLo
-	movw	CurrentPeriodPointer,ya
-	
-	pop	y					;get corresponding value in 14bit period table
-	mov	a,[CurrentPeriodPointer]+y				;get current period
-	mov	TempBuffer1,a
-	mov	PeriodBufferLo,a
-	inc	y
-	mov	a,[CurrentPeriodPointer]+y
-	mov	TempBuffer2,a
-	mov	PeriodBufferHi,a
-
-;fetch pitch from pitch table. input: period	
-	mov	y,TempBuffer2		
-	mov	a,TempBuffer1
-	addw	ya,TempBuffer1		;multiply by 2
-	addw	ya,PitchTablePointerLo	;add table offset	
-	movw	TempBuffer1,ya				;move adress to pointer
-	mov	y,#0
-
-	mov	a,[TempBuffer1]+y				;get lo pitch byte	
-	mov	PitchBufferLo,a			;save new pitch
-	inc	y
-	mov	a,[TempBuffer1]+y
-	mov	PitchBufferHi,a
-;fetch pitch end	
-	
-	mov	y,#ch_current_pitch_lo			;save new pitch to array
-	mov	a,PitchBufferLo
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,PitchBufferHi
-	mov	[CurrentChDataLo]+y,a
-	
-	mov	y,#ch_amiga_period_lo			;save new period to array
-	mov	a,PeriodBufferLo
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,PeriodBufferHi
-	mov	[CurrentChDataLo]+y,a
-	mov	y,#ch_vibrato_tremolo_waveform			;check vibrato waveform
-	mov	a,[CurrentChDataLo]+y
-	cmp	a,#$04
-	bne	VibratoRetrigger
-
-	mov	y,#ch_vibrato_position			;reset vibrato position
-	mov	a,#$00
-	mov	[CurrentChDataLo]+y,a
-
-VibratoRetrigger:
-	mov	y,#ch_vibrato_tremolo_waveform
-	mov	a,[CurrentChDataLo]+y
-	cmp	a,#$40
-	bne	VibratoNoWaveformReset
-
-	mov	y,#ch_tremolo_position
-	mov	a,#$00
-	mov	[CurrentChDataLo]+y,a
-
-VibratoNoWaveformReset:
-	mov	a,CurrentChannel
-	or	 a,#$02
-	mov	x,a
-	mov	y,#ch_current_pitch_lo
-	mov	a,[CurrentChDataLo]+y
-	mov	$f2,x			;set pitch height(hi), dsp reg $x2
-	mov	$f3,a
-	inc	y
-	inc	x
-	mov	a,[CurrentChDataLo]+y
-	
-	mov	$f2,x			;set pitch height(lo), dsp reg $x3
-	mov	$f3,a
-	inc	x
-	
-	mov	y,#ch_instrument			;set source sample number
-	mov	a,[CurrentChDataLo]+y
-	beq	DontUpdateSourceSampleNumber
-	mov	$f2,x
-	mov	$f3,a
-	inc	x
-	mov	$f2,x			;disable adsr, enable gain
-	mov	$f3,#$00			;old #$0c
-	inc	x
-
-	mov	$f2,x			;clear adsr2
-	mov	$f3,#$00			
-	inc	x
-	inc	x
-	mov	y,#ch_current_channelmask
-	mov	a,[CurrentChDataLo]+y			;trigger note
-	or	 a,KeyOn			;set note in key on var
-	mov	KeyOn,a
-DontUpdateSourceSampleNumber:
-	jmp	!GetDataFromPatternCheckEffects
-
-GetPitchFromBufferAndSet:
-	mov	a,CurrentChannel
-	or	 a,#$02
-	mov	x,a
-	mov	y,#ch_current_pitch_lo
-	mov	a,[CurrentChDataLo]+y
-	mov	$f2,x
-	mov	$f3,a
-	inc	x
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	$f2,x
-	mov	$f3,a
-	ret
-
-
-CheckForTickBasedEffects:
-;check if note cutoff is due
-
-	mov	y,#ch_effect
-	mov	a,[CurrentChDataLo]+y
-	cmp	a,#$ff
-	beq	GetPitchFromBufferAndSet
-;check for special effects:
-	and	a,#$0f
-	asl	a
-	mov	x,a			;use effect command as pointer into jump table
-	jmp	[!TickBasedEffectJumpTable+x]
-	
-TickBasedEffectJumpTable:	
-	.dw TickBasedArpeggio
-	.dw TickBasedPortamentoUp
-	.dw TickBasedPortamentoDown
-	.dw TickBasedTonePortamento
-	.dw TickBasedVibrato
-	.dw TickBasedVolslidePorta
-	.dw VolslideVibrato
-	.dw TickBasedTremolo
-	.dw TickBasedVoid
-	.dw TickBasedVoid
-	.dw TickbasedVolslide
-	.dw TickBasedVoid
-	.dw TickBasedVoid
-	.dw TickBasedVoid
-	.dw TickBasedExEffects
-	.dw TickBasedVoid
-
-
-TickBasedVoid:
-	ret
-	
-TickBasedExEffects:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y		;get ex-effect subtype
-	and	a,#$f0
-	lsr a
-	lsr a
-	lsr a
-	mov	x,a			;use effect command as pointer into jump table
-	jmp	[!TickBasedExEffectJumpTable+x]
-
-TickBasedExEffectJumpTable:
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-	.dw TickBasedExEffectNoteRetrigger
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-	.dw TickBasedExEffectNoteCutOff
-	.dw TickBasedExEffectNoteDelay
-	.dw TickBasedExVoid
-	.dw TickBasedExVoid
-
-TickBasedExVoid:
-	ret
-
-;check for special effects commands
-GetDataFromPatternCheckEffects:
-	mov	y,#ch_effect
-	mov	a,[CurrentChDataLo]+y
-	cmp	a,#$ff			;no effect present?
-	beq	GetPitchFromBufferAndSetLong
-
-	and	a,#$0f
-
-	asl	a
-	mov	x,a			;use effect command as pointer into jump table
-	jmp	[!NormalEffectJumpTable+x]
-	
-NormalEffectJumpTable:
-	.dw GetPitchFromBufferAndSet
-	.dw GetPitchFromBufferAndSet
-	.dw GetPitchFromBufferAndSet
-	.dw GetPitchFromBufferAndSet
-	.dw GetPitchFromBufferAndSet
-	.dw GetPitchFromBufferAndSet
-	.dw GetPitchFromBufferAndSet
-	.dw GetPitchFromBufferAndSet
-	.dw GetPitchFromBufferAndSet
-	.dw SetSampleOffset
-	.dw GetPitchFromBufferAndSet
-	.dw PositionJump
-	.dw EffectSetVolume
-	.dw PatternBreak
-	.dw GetDataFromPatternCheckExEffects
-	.dw SetSpeed0x0F
-
-GetPitchFromBufferAndSetLong:
-	jmp	!GetPitchFromBufferAndSet
-	
-;these are the special $Ex effects
-GetDataFromPatternCheckExEffects:
-
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$f0
-	mov	y,a			;save a
-	xcn	a
-	asl	a
-	mov	x,a			;pointer into jump table
-
-	jmp	[!ExEffectJumpTable+x]
-	
-ExEffectJumpTable:
-	.dw ExEffectSpecialReportCmd
-	.dw FinePortamentoUp
-	.dw FinePortamentoDown
-	.dw ExEffectVoid	
-	.dw SetVibratoWaveform
-	.dw Finetune
-	.dw PatternLoop
-	.dw ExEffectVoid
-	.dw ExEffectVoid
-	.dw EffectNoteRetrigger
-	.dw FineVolSlideUp
-	.dw FineVolSlideDown
-	.dw EffectNoteCutOff
-	.dw EffectNoteDelay
-	.dw ExEffectVoid
-	.dw ExEffectVoid
-	
-
-ExEffectVoid:
-	ret
-	
-
-TickBasedArpeggio:
-	mov	y,#ch_finetune				;calculate finetune
-	mov	a,[CurrentChDataLo]+y
-	mov	y,#$48
-	mul	ya
-	addw	ya,PeriodTablePointerLo
-	movw	CurrentPeriodPointer,ya
-	
-	mov	y,#ch_current_pitch_lo
-	mov	a,[CurrentChDataLo]+y		;save current pitch to buffer
-	mov	PitchBufferLo,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	PitchBufferHi,a
-	jmp	!ArpeggioToneSelector
-
-TickBasedVolslidePorta:
-	call	!TonePortamentoContinue
-	jmp	!TickbasedVolslide
-VolslideVibrato:
-	call	!ContinueVibrato
-	jmp	!TickbasedVolslide
-
-
-
-
-ArpeggioToneSelector:
-	mov	a,WaitCounter		;get waitcounter
-	mov	y,#0			;clear y
-	mov	x,#3			;put 3 into x
-	div	ya,x			;divide waitcounter by three
-	
-	mov	TempBuffer1,y		;put remainder(can take values 0-2) into TempBuffer1
-	
-	cmp	TempBuffer1,#$01
-	beq	ArpeggioTone1
-
-	cmp	TempBuffer1,#$02
-	beq	ArpeggioTone2
-
-	cmp	TempBuffer1,#$00
-	beq	ArpeggioTone3
-	
-		
-	ret
-
-ArpeggioTone1:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	xcn	a
-	and	a,#$0f
-	bra	ArpeggioCommit
-
-ArpeggioTone2:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	bra	ArpeggioCommit
-
-ArpeggioTone3:
-	mov	y,#ch_current_pitch_lo				;use current tone as pitch, unchanged
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer1,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a
-	bra	ArpeggioSetPitch
-
-ArpeggioCommit:
-	asl	a
-	mov	TempBuffer1,a
-	mov	y,#ch_arpeggio_note_buffer
-	mov	a,[CurrentChDataLo]+y
-	clrc
-	adc	a,TempBuffer1
-	mov	y,a
-
-	mov	a,[CurrentPeriodPointer]+y				;get current period
-	mov	ScratchPad1,a
-	inc	y
-	mov	a,[CurrentPeriodPointer]+y
-	mov	ScratchPad2,a
-	
-	mov	y,ScratchPad2		
-	mov	a,ScratchPad1
-	addw	ya,ScratchPad1		;multiply by 2
-	addw	ya,PitchTablePointerLo	;add table offset	
-	movw	ScratchPad1,ya				;move adress to pointer
-	mov	y,#0
-
-	mov	a,[ScratchPad1]+y				;get lo pitch byte	
-	mov	TempBuffer1,a			;save new pitch
-	inc	y
-	mov	a,[ScratchPad1]+y
-	mov	TempBuffer2,a
-
-
-ArpeggioSetPitch:
-	mov	a,CurrentChannel
-	or	 a,#$02
-	mov	$f2,a
-	mov	$f3,TempBuffer1
-	inc	a
-	mov	$f2,a
-	mov	$f3,TempBuffer2
-	ret
-
-FinePortamentoUp:
-	cmp	WaitCounter,#$00
-	bne	PortamentoExit				
-
-	mov	PortamentoSpeedMask,#$0f				;portamento up, but only with lower nibble of effect value
-
-TickBasedPortamentoUp:
-	mov	a, #(HighestPortaPeriod & $00ff)
-	mov	y, #(HighestPortaPeriod	>> 8)
-	movw	TempBuffer5,ya			;put highest slideable period into buffer
-	
-	mov	y,#ch_amiga_period_lo				;get current period
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer1,a			;and save it to temp buffer
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a
-
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y		;get current effect value
-	and	a,PortamentoSpeedMask		;and with mask depeding on normal or finetune portamento
-	mov	y,#$00				;inverse clear y
-	movw	TempBuffer3,ya			;put ya into tempbuffer3
-	movw	ya,TempBuffer1			;get current period
-	subw	ya,TempBuffer3			;substract portamento speed
-
-	cmpw	ya,TempBuffer5			;if negative, we've slided too high
-	bpl	PortaUpNoLimit
-
-	movw	ya,TempBuffer5		;use limit value if we've slided too high
-
-PortaUpNoLimit:	
-	movw	TempBuffer1,ya		;put new pitch to buffer
-
-	mov	y,#ch_amiga_period_lo				;save back current period
-	mov	a,TempBuffer1
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,TempBuffer2
-	mov	[CurrentChDataLo]+y,a
-	
-	mov	y,TempBuffer2		;get current period	
-	mov	a,TempBuffer1
-	addw	ya,TempBuffer1		;multiply by 2
-	addw	ya,PitchTablePointerLo	;add table offset	
-	movw		TempBuffer3,ya				;move adress to pointer
-	mov	y,#0
-
-	mov	a,[TempBuffer3]+y				;get lo pitch byte	
-	mov	TempBuffer1,a			;save new pitch
-	inc	y
-	mov	a,[TempBuffer3]+y
-	mov	TempBuffer2,a	
-	
-	
-	mov	y,#ch_current_pitch_lo		;save new pitch to current pitch and update pitch register
-	mov	a,TempBuffer1
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,TempBuffer2
-	mov	[CurrentChDataLo]+y,a
-	mov	a,CurrentChannel
-	or	 a,#$02
-	mov	$f2,a
-	mov	$f3,TempBuffer1
-	inc	a
-	mov	$f2,a
-	mov	$f3,TempBuffer2
-
-PortamentoExit:
-	mov	PortamentoSpeedMask,#$ff
-	ret
-
-FinePortamentoDown:
-	cmp	WaitCounter,#$00
-	bne	PortamentoExit
-
-	mov	PortamentoSpeedMask,#$0f
-
-TickBasedPortamentoDown:
-
-	mov	a, #(LowestPortaPeriod & $00ff)
-	mov	y, #(LowestPortaPeriod	>> 8)
-	movw	TempBuffer5,ya			;put lowest slideable period into buffer
-	
-	mov	y,#ch_amiga_period_lo				;get current period
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer1,a			;and save it to temp buffer
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a
-
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y		;get current effect value
-	and	a,PortamentoSpeedMask		;and with mask depeding on normal or finetune portamento
-	mov	y,#$00				;inverse clear y
-	addw	ya,TempBuffer1			;add portamento speed
-
-	cmpw	ya,TempBuffer5			;if positive, we've slided too high
-	bmi	PortaDownNoLimit
-
-	movw	ya,TempBuffer5		;use limit value if we've slided too high
-
-PortaDownNoLimit:	
-	movw	TempBuffer1,ya		;put new pitch to buffer
-
-	mov	y,#ch_amiga_period_lo				;save back current period
-	mov	a,TempBuffer1
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,TempBuffer2
-	mov	[CurrentChDataLo]+y,a
-	
-	mov	y,TempBuffer2		;get current period	
-	mov	a,TempBuffer1
-	addw	ya,TempBuffer1		;multiply by 2
-	addw	ya,PitchTablePointerLo	;add table offset	
-	movw		TempBuffer3,ya				;move adress to pointer
-	mov	y,#0
-
-	mov	a,[TempBuffer3]+y				;get lo pitch byte	
-	mov	TempBuffer1,a			;save new pitch
-	inc	y
-	mov	a,[TempBuffer3]+y
-	mov	TempBuffer2,a
-	
-		
-		
-	mov	y,#ch_current_pitch_lo
-	mov	a,TempBuffer1
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,TempBuffer2
-	mov	[CurrentChDataLo]+y,a
-	mov	a,CurrentChannel
-	or	 a,#$02
-	mov	$f2,a
-	mov	$f3,TempBuffer1
-	inc	a
-	mov	$f2,a
-	mov	$f3,TempBuffer2
-	ret
-
-TonePortamento:
-	mov	y,#ch_note							;get note
-	mov	a,[CurrentChDataLo]+y
-	mov	y,a				;put period in y
-	push	y
-	mov	y,#ch_finetune				
-	mov	a,[CurrentChDataLo]+y		;calculate finetune
-	mov	y,#$48
-	mul	ya
-	addw	ya,PeriodTablePointerLo
-	movw	CurrentPeriodPointer,ya
-	
-	pop	y					;get corresponding value in 14bit period table
-	mov	a,[CurrentPeriodPointer]+y				;get current period
-	mov	PeriodBufferLo,a
-	inc	y
-	mov	a,[CurrentPeriodPointer]+y
-	mov	PeriodBufferHi,a
-
-	mov	y,#ch_current_amiga_period_lo							;this is our target period to slide to				
-	mov	a,PeriodBufferLo
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,PeriodBufferHi
-	mov	[CurrentChDataLo]+y,a
-
-	mov	y,#ch_amiga_period_lo							;get current actual period
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer1,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a	
-	
-	
-	mov	y,#ch_portamento_slide_dir
-	mov	a,#$00
-	mov	[CurrentChDataLo]+y,a
-	movw	ya,PeriodBufferLo
-	cmpw	ya,TempBuffer1
-	beq	TonePortamentoEqual					;check if already at target period
-
-	bmi	TonePortamentoExit					;if plus, the target period is higher(tone is lower) than the current period. slide value must be added in that case
-
-	mov	y,#ch_portamento_slide_dir							;invert sliding direction
-	mov	a,#$01
-	mov	[CurrentChDataLo]+y,a
-
-TonePortamentoExit:
-	ret
-
-TonePortamentoEqual:
-	mov	y,#ch_current_amiga_period_lo
-	mov	a,#$00
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	[CurrentChDataLo]+y,a
-	ret
-
-TickBasedTonePortamento:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y		;get effect data (tone portamento speed value)
-	beq	TonePortamentoContinue		;if zero, continue and dont alter period
-
-	mov	y,#ch_tone_portamento_speed				;save speed
-	mov	[CurrentChDataLo]+y,a
-	mov	y,#ch_effect_data				;clear effect data
-	mov	a,#$00
-	mov	[CurrentChDataLo]+y,a
-
-TonePortamentoContinue:
-	mov	y,#ch_current_amiga_period_lo				;get target period, put into tempbuffer1
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer1,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a
-	
-	
-	movw	ya,TempBuffer1			;exit if target period is zero (set before if target period has already been reached
-	beq	TonePortamentoExit
-	mov	y,#ch_tone_portamento_speed
-	mov	a,[CurrentChDataLo]+y		;get current speed value (tone portamento speed)
-	mov	y,#$00				;clear y
-	movw	TempBuffer3,ya			;put slide amount into tempbuffer3
-	
-	mov	y,#ch_portamento_slide_dir
-	mov	a,[CurrentChDataLo]+y
-	bne	TonePortaSlideDown		;check whether to slide up or down
-
-	mov	y,#ch_amiga_period_lo				;get current period, put into TempBuffer5
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer5,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer6,a
-	
-	movw	ya,TempBuffer5			;get current period
-	subw	ya,TempBuffer3			;substract slidespeed
-	cmpw	ya,TempBuffer1			;check for overflow
-	bpl	TonePortaSlideDone
-
-	mov	y,#ch_current_amiga_period_lo				;if overflow occured, clear tone porta target period
-	mov	a,#$00
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	[CurrentChDataLo]+y,a
-	movw	ya,TempBuffer1			;and load target period instead
-	bra	TonePortaSlideDone
-
-TonePortaSlideDown:
-	mov	y,#ch_amiga_period_lo				;get current period, put into TempBuffer5
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer5,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer6,a
-	
-	movw	ya,TempBuffer5			;get current period
-	addw	ya,TempBuffer3			;substract slidespeed
-	cmpw	ya,TempBuffer1			;check for overflow
-	bmi	TonePortaSlideDone
-
-	mov	y,#ch_current_amiga_period_lo				;if overflow occured, clear tone porta target period
-	mov	a,#$00
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	[CurrentChDataLo]+y,a
-	movw	ya,TempBuffer1			;and load target period instead
-;	bra	TonePortaSlideDone
-
-TonePortaSlideDone:
-	movw	TempBuffer1,ya			;save newly calculated period to current period buffer
-
-	mov	y,#ch_amiga_period_lo				;save to current period buffer
-	mov	a,TempBuffer1
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,TempBuffer2
-	mov	[CurrentChDataLo]+y,a
-
-;fetch pitch from pitch table. input: period	
-	movw	ya,TempBuffer1		
-	addw	ya,TempBuffer1		;multiply by 2
-	addw	ya,PitchTablePointerLo	;add table offset	
-	movw	TempBuffer1,ya				;move adress to pointer
-	mov	y,#0
-
-	mov	a,[TempBuffer1]+y				;get lo pitch byte	
-	mov	TempBuffer5,a			;save new pitch
-	inc	y
-	mov	a,[TempBuffer1]+y
-	mov	TempBuffer6,a
-
-
-	mov	y,#ch_current_pitch_lo				;save to current pitch buffer
-	mov	a,TempBuffer5
-	mov	[CurrentChDataLo]+y,a
-	inc	y
-	mov	a,TempBuffer6
-	mov	[CurrentChDataLo]+y,a
-	mov	a,CurrentChannel
-	or	 a,#$02
-	mov	$f2,a				;write to dsp
-	mov	$f3,TempBuffer5
-	inc	a
-	mov	$f2,a
-	mov	$f3,TempBuffer6
-	ret
-
-TickBasedVibrato:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y		;if speed & depth are zero, continue vibrato without updating em.
-	beq	ContinueVibrato
-
-	mov	TempBuffer1,a
-	mov	y,#ch_vibrato_command_buffer				;get vibrato speed & depth buffer
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a
-	and	TempBuffer1,#$0f
-	beq	VibratoSkipDepthUpdate		;dont update depth if its zero
-
-	and	TempBuffer2,#$f0			;update buffer
-	or	 TempBuffer2,TempBuffer1
-
-VibratoSkipDepthUpdate:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y		;get vibrato speed
-	mov	TempBuffer1,a
-	and	TempBuffer1,#$f0
-	beq	VibratoSkipSpeedUpdate		;dont upgrade speed if its zero
-
-	and	TempBuffer2,#$0f			;update buffer
-	or	 TempBuffer2,TempBuffer1
-
-VibratoSkipSpeedUpdate:
-	mov	y,#ch_vibrato_command_buffer
-	mov	a,TempBuffer2			;save back updated vibrato speed & depth
-	mov	[CurrentChDataLo]+y,a
-
-ContinueVibrato:
-	mov	y,#ch_vibrato_position
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a			;get current vibrato position, this is our pointer into the vibrato table
-	lsr	TempBuffer2
-	lsr	TempBuffer2
-	and	TempBuffer2,#$1f			;divide by 4 and limit
-	mov	y,#ch_vibrato_tremolo_waveform			
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$03				;select current waveform
-	mov	TempBuffer3,a
-	beq	VibratoSelectSine
-
-	asl	TempBuffer2			;multiply table pointer with 8
-	asl	TempBuffer2
-	asl	TempBuffer2
-	cmp	a,#$01
-	beq	VibratoSelectRampDown
-
-	mov	TempBuffer3,#$ff			;this is square vibrato
-	bra	VibratoSelectSet
-
-VibratoSelectRampDown:
-	mov	y,#ch_vibrato_position
-	mov	a,[CurrentChDataLo]+y		;get current vibrato position
-	bpl	VibratoSet
-
-	mov	TempBuffer3,#$ff
-	setc
-	sbc	TempBuffer3,TempBuffer2
-	bra	VibratoSelectSet
-
-VibratoSet:
-	mov	TempBuffer3,TempBuffer2
-	bra	VibratoSelectSet
-
-VibratoSelectSine:
-	mov	x,TempBuffer2
-	mov	a,!VibratoTable+x			;access vibrato table
-	mov	TempBuffer3,a
-
-VibratoSelectSet:
-	mov	y,#ch_vibrato_command_buffer					
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f				;get current vibrato depth		
-	mov	y,TempBuffer3
-	mul	ya				;multiply with selected vibrato position
-	movw	TempBuffer5,ya
-	mov	y,#$07
-
-VibratoDivLoop:
-	lsr	TempBuffer6			;divide by 128
-	ror	TempBuffer5
-	dbnz	y,VibratoDivLoop
-	
-	mov	y,#ch_amiga_period_lo				;get current period
-	mov	a,[CurrentChDataLo]+y
-	mov	PitchBufferLo,a
-	inc	y
-	mov	a,[CurrentChDataLo]+y
-	mov	PitchBufferHi,a
-	mov	y,#ch_vibrato_position
-	mov	a,[CurrentChDataLo]+y		;get vibrato position
-	bmi	VibratoPosNegative
-
-
-	movw	ya,PitchBufferLo
-	subw	ya,TempBuffer5
-	bra	VibratoUpdatePitch
-
-VibratoPosNegative:
-	movw	ya,PitchBufferLo
-	addw	ya,TempBuffer5
-
-VibratoUpdatePitch:
-	movw	PitchBufferLo,ya			;this is our new period
-	addw	ya,PitchBufferLo		;multiply by 2
-	addw	ya,PitchTablePointerLo		;add table offset	
-	movw	ScratchPad1,ya			;move adress to pointer
-	mov	y,#0
-
-	mov	a,[ScratchPad1]+y				;get lo pitch byte	
-	mov	PitchBufferLo,a			;save new pitch
-	inc	y
-	mov	a,[ScratchPad1]+y
-	mov	PitchBufferHi,a
-
-	
-	mov	a,CurrentChannel			;write pitch to dsp
-	or	 a,#$02
-	mov	$f2,a
-	mov	$f3,PitchBufferLo
-	inc	a
-	mov	$f2,a
-	mov	$f3,PitchBufferHi
-
-
-	mov	y,#ch_vibrato_command_buffer
-	mov	a,[CurrentChDataLo]+y
-	lsr	a
-	lsr	a
-	and	a,#$3c
-	mov	TempBuffer1,a
-	mov	y,#ch_vibrato_position
-	mov	a,[CurrentChDataLo]+y
-	clrc
-	adc	a,TempBuffer1
-	mov	[CurrentChDataLo]+y,a
-	ret
-
-TickBasedTremolo:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	beq	TremoloContinue
-
-
-	mov	TempBuffer1,a
-	mov	y,#ch_tremolo_command_buffer
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a
-	and	TempBuffer1,#$0f
-	beq	TremoloNoNewSpeed
-
-	and	TempBuffer2,#$f0
-	or	 TempBuffer2,TempBuffer1
-
-TremoloNoNewSpeed:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer1,a
-	and	TempBuffer1,#$f0
-	beq	TremoloNoNewDepth
-
-	and	TempBuffer2,#$0f
-	or	 TempBuffer2,TempBuffer1
-
-TremoloNoNewDepth:
-	mov	y,#ch_tremolo_command_buffer
-	mov	a,TempBuffer2
-	mov	[CurrentChDataLo]+y,a
-
-TremoloContinue:
-	mov	y,#ch_tremolo_position
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer2,a
-	lsr	TempBuffer2
-	lsr	TempBuffer2
-	and	TempBuffer2,#$1f
-	mov	y,#ch_vibrato_tremolo_waveform
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer3,a
-	lsr	TempBuffer3
-	lsr	TempBuffer3
-	lsr	TempBuffer3
-	lsr	TempBuffer3
-	and	TempBuffer3,#$03
-	beq	TremolWavSel
-
-
-	asl	TempBuffer2
-	asl	TempBuffer2
-	asl	TempBuffer2
-	asl	TempBuffer2
-	cmp	TempBuffer3,#$01
-	beq	TremolWavSel2
-
-	mov	TempBuffer3,#$ff
-	bra	TremoloCommit
-
-TremolWavSel2:
-	mov	y,#ch_vibrato_position
-	mov	a,[CurrentChDataLo]+y
-	bpl	TremoloCommit2
-
-	mov	TempBuffer3,#$ff
-	setc
-	sbc	TempBuffer3,TempBuffer2
-	bra	TremoloCommit
-
-TremoloCommit2:
-	mov	TempBuffer3,TempBuffer2
-	bra	TremoloCommit
-
-TremolWavSel:
-	mov	x,TempBuffer2
-	mov	a,!VibratoTable+x			;access table #2
-	mov	TempBuffer3,a
-
-TremoloCommit:
-	mov	y,#ch_tremolo_command_buffer
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	mov	y,TempBuffer3
-	mul	ya
-	movw	TempBuffer5,ya
-	mov	y,#$06
-
-TremolDivLoop:
-	lsr	TempBuffer6
-	ror	TempBuffer5
-	dbnz	y,TremolDivLoop
-	
-	mov	y,#ch_current_volume
-	mov	a,[CurrentChDataLo]+y
-	mov	TempBuffer1,a
-	mov	y,#ch_tremolo_position
-	mov	a,[CurrentChDataLo]+y
-	bmi	TremolPosNeg
-
-	clrc
-	adc	TempBuffer1,TempBuffer5
-	bra	TremolPosPos
-
-TremolPosNeg:
-	setc
-	sbc	TempBuffer1,TempBuffer5
-
-TremolPosPos:
-	bpl	TremolPosRes
-
-	mov	TempBuffer1,#$00
-
-TremolPosRes:
-	cmp	TempBuffer1,#$40
-	bmi	TremolPosRes2
-
-	mov	TempBuffer1,#$40
-
-TremolPosRes2:
-	mov	a,CurrentChannel
-	or	 a,#$00
-	mov	$f2,a
-	mov	$f3,TempBuffer1
-	inc	a
-	mov	$f2,a
-	mov	$f3,TempBuffer1
-	mov	y,#ch_tremolo_command_buffer
-	mov	a,[CurrentChDataLo]+y
-	lsr	a
-	lsr	a
-	and	a,#$3c
-	mov	TempBuffer1,a
-	mov	y,#ch_tremolo_position
-	mov	a,[CurrentChDataLo]+y
-	clrc
-	adc	a,TempBuffer1
-	mov	[CurrentChDataLo]+y,a
-	ret
-
-TickbasedVolslide:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	xcn	a
-	and	a,#$0f
-	beq	TickbasedVolSlideDown
-
-	mov	TempBuffer1,a
-
-VolSlideUp:
-	mov	y,#ch_current_volume
-	mov	a,[CurrentChDataLo]+y
-	adc	a,TempBuffer1
-	cmp	a,#$40
-	bmi	VolSlideUpNoWaveformReset
-
-	mov	a,#$40
-
-VolSlideUpNoWaveformReset:
-	mov	[CurrentChDataLo]+y,a
-	mov	CurrentVolume,a
-
-	call	!SetVolumeVibrato
-	
-	ret
-
-TickbasedVolSlideDown:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	mov	TempBuffer1,a
-
-VolSlideDown:
-	mov	y,#ch_current_volume
-	mov	a,[CurrentChDataLo]+y
-	sbc	a,TempBuffer1
-	bpl	VolSlideDownNoReset
-
-	mov	a,#$00
-
-VolSlideDownNoReset:
-	mov	[CurrentChDataLo]+y,a
-	mov	CurrentVolume,a
-	call	!SetVolumeVibrato
-
-
-	
-	ret
-
-SetSpeed0x0F:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	mov	PatternSpeed,a			;self-modifying code
-	dec	a
-	mov	NextRowChFadeOutTime,a
-	ret
-
-SetSampleOffset:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	mov	x,a
-	mov	a,#0
-	mov	y,#0
-	mov	TempBuffer3,#$90			;512/16*9=288, $120
-	mov	TempBuffer4,#$00
-
-SetSampleOffsetCalcLoop:	
-	cmp	x,#0
-	beq SetSampleOffsetCalcLoopDone
-
-	addw	ya,TempBuffer3
-	dec	x
-	bra SetSampleOffsetCalcLoop
-
-SetSampleOffsetCalcLoopDone:
-	movw	TempBuffer1,ya
-			
-	mov	y,#ch_instrument
-	mov	a,[CurrentChDataLo]+y
-	asl	a
-	asl	a
-	mov	x,a
-	mov	a,!SampleSource+x			;create a new sample (#3f) that plays with the modified start position
-	mov	TempBuffer5,a
-	mov	!(SampleSource+(ExtSample*4)),a
-	mov	a,!(SampleSource+1)+x
-	mov	TempBuffer6,a
-	mov	!(SampleSource+1+(ExtSample*4)),a
-	mov	a,!(SampleSource+2)+x
-	mov	!(SampleSource+2+(ExtSample*4)),a
-	mov	a,!(SampleSource+3)+x
-	mov	!(SampleSource+3+(ExtSample*4)),a
-	movw	ya,TempBuffer5
-	addw	ya,TempBuffer1
-	movw	TempBuffer5,ya
-	mov	a,TempBuffer5
-	mov	!(SampleSource+(ExtSample*4)),a
-	mov	a,TempBuffer6
-	mov	!(SampleSource+1+(ExtSample*4)),a
-	mov	a,CurrentChannel
-	or	 a,#$04
-	mov	$f2,a
-	mov	$f3,#ExtSample
-	ret
-
-PositionJump:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	mov	CurrentPatternNumber,a
-	mov	x,a
-	mov	a,!(ModFile+$fa)+x
-	asl	a
-	mov	x,a
-	mov	a,!(ModFile+$17a)+x
-	mov	y,a
-	mov	a,!(ModFile+$17b)+x
-	addw	ya,InitPatternPointerLo
-	movw	CurrentPatternPointerLo,ya
-	pop	a							;need to purge the stack a bit first
-	pop	a							;else, it would overflow slowly when using the pattern break command constantly
-	pop	a
-	pop	a
-	pop	a
-	pop	a
-
-	jmp	!MainLoop
-
-
-;set channel volume:
-EffectSetVolume:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-
-
-	mov	y,#ch_current_volume
-	mov	[CurrentChDataLo]+y,a
-	
-	mov	CurrentVolume,a
-	call	!SetVolume
-	ret
-
-PatternBreak:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y					;get break row.
-	bne	PatternBreakZero						;only breaks to row #0 of next pattern are supported. else dont do anything
-
-	mov	PatternBreakFlag,#1					;set break flag. the actual break gets executed after the current row has been completely processed
-PatternBreakZero:
-	ret
-
-
-ExEffectSpecialReportCmd:
-	inc SpecialReportCmd		;increase special cmd counter.
-	ret
-	
-SetVibratoWaveform:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	mov	TempBuffer1,a
-	mov	y,#ch_vibrato_tremolo_waveform							;update vibrato waveform
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$f0
-	or	 a,TempBuffer1
-	mov	[CurrentChDataLo]+y,a
-	ret
-
-Finetune:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	mov	y,#ch_finetune						;whats written to chdata $04 here?
-	mov	[CurrentChDataLo]+y,a
-	ret
-
-FineVolSlideUp:
-	mov	a,WaitCounter
-	bne	FineVolSlideUpCancel
-
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	mov	TempBuffer1,a
-	jmp	!VolSlideUp
-
-FineVolSlideUpCancel:
-	ret
-
-FineVolSlideDown:
-	mov	a,WaitCounter
-	bne	FineVolSlideDownCancel
-
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	mov	TempBuffer1,a
-	jmp	!VolSlideDown
-
-FineVolSlideDownCancel:
-	ret
-
-InitVariables:
-	mov	WaitCounter,#$00
-	mov	a,#$06
-	mov	PatternSpeed,a		;self-modifying code
-	dec	a
-	mov	NextRowChFadeOutTime,a
-	mov	LoopCounter,#0
-	mov	CurrentPatternNumber,#$00
-	mov	PortamentoSpeedMask,#$ff
-	mov	a,!(ModFile+$f8)			;$13d3
-	mov	NumberOfPatterns,a
-	mov	TempBuffer1,#$fc			;initial relative adress of pattern tables
-	mov	TempBuffer2,#$01
-	movw	ya,ModFilePointerLo
-	movw	ModFilePointer2Lo,ya		
-	addw	ya,TempBuffer1			
-	movw	CurrentPatternPointerLo,ya
-	movw	InitPatternPointerLo,ya
-	movw	CurrentLoopPointerLo,ya
-	mov	a,!(ModFile+$fa)			;load initial pattern.
-	asl	a
-	mov	x,a
-	mov	a,!(ModFile+$17a)+x			;get pointer to pattern
-	mov	y,a
-	mov	a,!(ModFile+$17b)+x
-	addw	ya,InitPatternPointerLo
-	movw	CurrentPatternPointerLo,ya
-
-	mov	a,#(PeriodTable & $00ff)			;set pointer to amiga period table
-	mov	PeriodTablePointerLo,a
-	mov	a,#(PeriodTable >> 8)
-	mov	PeriodTablePointerHi,a
-
-	mov	a,#(PitchTable & $00ff)			;set pointer to snes pitch table
-	mov	PitchTablePointerLo,a
-	mov	a,#(PitchTable >> 8)
-	mov	PitchTablePointerHi,a
-	mov	PatternBreakFlag,#0
-
-	mov	SpecialReportCmd,#0
-
-	ret
-
-PortamentoDownLimit:
-	.dw $01e3
-
-;set reset some dsp registers:
-SetupDspRegsAndTimers:
-	mov	$f1,#$00							;stop timers
-	mov		a,$fd									;clear 4bit counters
-	mov		a,$fe									;clear 4bit counters
-	mov		a,$ff									;clear 4bit counters
-	mov	SongChannelMask,#$0f		;enable all 4 mod channels
-	mov	ModPlayerTimer0,#$a0			
-	mov	$fa,ModPlayerTimer0			;20 milliSeconds on timer 0
-	mov	$fb,#$10			;2 milliSeconds on timer 1
-
-	nop
-	nop
-	mov	$f1,#$03			;start timer(s)
-
-	mov	a,#$00			;clear all dsp regs
-	mov	x,a
-
-DspRegClearLoop:
-	cmp	x,#$6c
-	bne	DspRegClearLoopEchoSkip
-
-	mov	$f2,x			;disable echo
-	mov	$f3,#$20
-	inc	x
-	
-DspRegClearLoopEchoSkip:	
-	mov	$f2,x
-	mov	$f3,a
-	inc	x
-	bpl	DspRegClearLoop
-
-	mov	$f2,#$5d			;setup dsp regs
-	mov	$f3,#(SampleSource >> 8)			;this is the sample info loaction (dir)
-	mov	$f2,#$6c
-	mov	$f3,#$20
-	mov	$f2,#$0c			;set master volume
-	mov	$f3,MainVolL
-	mov	$f2,#$1c
-	mov	$f3,MainVolR
-	mov	$f2,#$3d
-	mov	$f3,#$00
-	mov	$f2,#$7c
-	mov	$f3,a
-;setup echo stuff:
-
-;set filter:
-	mov	$f2,#$0f			;fir
-	mov	$f3,#$30
-	mov	$f2,#$1f			;fir
-	mov	$f3,#$00
-	mov	$f2,#$2f			;fir
-	mov	$f3,#$00
-	mov	$f2,#$3f			;fir
-	mov	$f3,#$00
-	mov	$f2,#$4f			;fir
-	mov	$f3,#$00
-	mov	$f2,#$5f			;fir
-	mov	$f3,#$00
-	mov	$f2,#$6f			;fir
-	mov	$f3,#$20
-	mov	$f2,#$7f			;fir
-	mov	$f3,#$30
-
-
-;setup adsr on channels 1-4:	
-	mov	a,CurrentChannel
-	push	a
-	mov	CurrentChannel,#$00		;channel 1
-	call	!SetupAdsr
-	mov	CurrentChannel,#$10		;channel 2
-	call	!SetupAdsr
-	mov	CurrentChannel,#$20		;channel 3
-	call	!SetupAdsr
-	mov	CurrentChannel,#$30		;channel 4
-	call	!SetupAdsr
-
-	pop	a
-
-
-	ret
-	
-SetupAdsr:
-	mov	a,#$05			;dsp reg $x5 (adsr1)
-	or	a,CurrentChannel			;or with channel number
-	mov	x,a
-	
-	mov	$f2,x			;set adsr 1 (winter gold example: $dc) new value: $cb (slower attack an decay)
-	mov	$f3,#$0e			;old #$0c
-	inc	x
-	mov	$f2,x			;set adsr 2 (winter gold example: $2d) new value: $36 (longer release)
-	mov	$f3,#$2d			;old #$2d
-	inc	x
-
-	mov	a,x
-	and	a,#$f0			;only get channel, not register
-	mov	x,a
-	mov	a,#$40
-	ret	
-
-
-SetupSamples:
-	mov	x,#$00
-	mov	y,#$00
-
-SetupSamplesLoop:
-	inc	y
-	mov	a,[ModFilePointerLo]+y		;get sample relative adress low
-	dec	y
-	clrc
-	adc	a,ModFilePointerLo		;add modfile position
-	mov		!(SampleSource+4)+x,a		;store in dsp sample area
-	mov	a,[ModFilePointerLo]+y		;get sample relative adress hi
-	adc	a,ModFilePointerHi		;add modfile position, with carry from previous add
-	mov	!(SampleSource+5)+x,a		;store in dsp sample area
-	inc	y
-	inc	y
-	inc	y
-	inc	y
-;repeat the same with loop adress:	
-	inc	y
-	mov	a,[ModFilePointerLo]+y		;get sample relative adress low
-	dec	y
-	clrc
-	adc	a,ModFilePointerLo		;add modfile position
-	mov		!(SampleSource+6)+x,a		;store in dsp sample area
-	mov	a,[ModFilePointerLo]+y		;get sample relative adress hi
-	adc	a,ModFilePointerHi		;add modfile position, with carry from previous add
-	mov	!(SampleSource+7)+x,a		;store in dsp sample area
-	inc	y
-	inc	y
-	inc	y
-	inc	y
-	inc	x
-	inc	x
-	inc	x
-	inc	x
-	cmp	x,#$7c
-	bne	SetupSamplesLoop
-	
-	ret
-	
-;old:
-	clrc
-	mov	a,!(ModFile+1)+x		;get sample location $12dc
-	adc	a,#(ModFile & $00ff)		;add #$12db
-	mov	!(SampleSource+4)+y,a		;store in dsp sample area
-	mov	a,!ModFile+x
-	adc	a,#(ModFile >> 8)
-	mov	!(SampleSource+5)+y,a
-	inc	x
-	inc	x
-	inc	x
-	inc	x
-	clrc
-	mov	a,!(ModFile+1)+x
-	adc	a,#(ModFile & $00ff)
-	mov	!(SampleSource+6)+y,a
-	mov	a,!ModFile+x
-	adc	a,#(ModFile >> 8)
-	mov	!(SampleSource+7)+y,a
-	inc	x
-	inc	x
-	inc	x
-	inc	x
-	inc	y
-	inc	y
-	inc	y
-	inc	y
-	cmp	y,#$7c
-	bne	SetupSamplesLoop
-
-
-
-	ret
-
-;setup stream sample adress, sample #33
-
-SetupStreamSampleAdress:
-	mov	a,#SpcStreamSampleNumber	;get number of sample to use
-	asl	a				;multiply by 4
-	asl	a
-	mov	y,a				;pointer into sample source table
-	
-	mov	a,#(StreamBuffer & $00ff)		;get 1st stream buffer adress
-	mov	!(SampleSource)+y,a		;store in dsp sample area
-	mov	!(SampleSource+2)+y,a
-	mov	a,#(StreamBuffer >> 8)
-	mov	!(SampleSource+1)+y,a
-	mov	!(SampleSource+3)+y,a
-	ret
-	
-KeyOnKeyOff:
-	mov	y,#0
-	mov	a,#$5c
-	movw	$f2,ya
-	mov	$f2,#$4c			
-	mov	a,KeyOn
-	and	a,SongChannelMask
-	mov	$f3,a
-	ret
-
-CutOffChannelGain:
-	mov	a,#$07				;select GAIN dsp reg
-	or	a,CurrentChannel		;
-	mov	$f2,a			;set gain	(winter gold example: $3d)
-	mov	$f3,#%10011111		;decrease volume, 8mS	;old #%10111111
-	mov	y,#ch_current_volume
-	mov	a,#0						;clear volume
-	mov	[CurrentChDataLo]+y,a
-	ret					;return
-
-
-
-
-
-SetVolumeVibrato:
-;set channel mod volume
-	mov	a,#$07				;select GAIN dsp reg
-	or	a,CurrentChannel		;
-	mov	$f2,a				;set gain
-	mov	a,CurrentVolume
-	and	a,#$7f				;set direct gain mode
-	mov	$f3,a	
-
-;set channel global volume
-	mov	a,CurrentChannel					;check active channel
-	cmp a,#0
-	beq SetVolumeLeftCh
-	cmp a,#$20
-	beq SetVolumeLeftCh
-
-	mov	y,MusicVol1
-	movw	$f2,ya
-	inc	a
-	mov	y,MusicVol2
-	movw	$f2,ya	
-	ret
-
-
-SetVolume:
-;set channel mod volume
-	mov	a,#$07				;select GAIN dsp reg
-	or	a,CurrentChannel		;
-	mov	$f2,a				;set gain
-	mov	y,#ch_current_volume
-	mov	a,[CurrentChDataLo]+y	
-	and	a,#$7f				;set direct gain mode
-	mov	$f3,a	
-
-;set channel global volume
-	mov	a,CurrentChannel					;check active channel
-	cmp a,#0
-	beq SetVolumeLeftCh
-	cmp a,#$20
-	beq SetVolumeLeftCh
-
-	mov	y,MusicVol1
-	movw	$f2,ya
-	inc	a
-	mov	y,MusicVol2
-	movw	$f2,ya	
-	ret
-
-
-SetVolumeLeftCh:
-	mov	y,MusicVol2
-	movw	$f2,ya
-	inc	a
-	mov	y,MusicVol1
-	movw	$f2,ya	
-	ret
-		
-	mov	a,CurrentChannel					;save current volume
-	mov	$f2,a
-	mov	a,$f3
-	mov	TempVol,a
-	
-SetVolumeLoop:
-	cmp	CurrentVolume,TempVol						;check if bigger or smaller
-	beq	SetVolumeExit
-	bmi	SetVolumeDec							;branch if old value is bigger than new
-
-	inc	TempVol
-	mov	a,CurrentChannel					;check active channel
-	mov	y,TempVol
-	movw	$f2,ya
-	inc	a
-	movw	$f2,ya
-	
-	bra	SetVolumeLoop
-
-SetVolumeDec:
-	dec	TempVol	
-	mov	a,CurrentChannel					;check active channel
-	mov	y,TempVol
-	movw	$f2,ya
-	inc	a
-	movw	$f2,ya	
-	bra	SetVolumeLoop
-
-
-SetVolumeExit:
-
-	ret
-
-
-
-
-	
-
-PreTestRow:
-	mov	y,#$00
-	mov	NextRowChFadeOuts,#$00
-	mov	CurrentChannel,#$01
-	call	!PreTestChannel
-	mov	CurrentChannel,#$02
-	call	!PreTestChannel
-	mov	CurrentChannel,#$04
-	call	!PreTestChannel
-	mov	CurrentChannel,#$08
-	jmp	!PreTestChannel
-	
-	
-PreTestChannel:
-	mov	a,[CurrentPatternPointerLo]+y
-	cmp	a,#$00
-	beq	PreTestChannelIsEffectOnly
-	cmp	a,#$ff			;compare if channel entry is $ff(skip)
-	beq	PreTestChannelIsVoid
-	
-	inc	y				;check if a period is present
-	mov	a,[CurrentPatternPointerLo]+y
-	cmp	a,#$ff
-	beq	PreTestChannelIsEffectOnly2
-	
-	inc	y
-	mov	a,[CurrentPatternPointerLo]+y
-	cmp	a,#3				;check if tone portamento (which doesnt actually play a new note, so the old one must not be muted)
-	beq	PreTestChannelIsEffectOnly3
-
-	and	a,#$0f
-	mov	TempBuffer1,a
-	inc	y
-	mov	a,[CurrentPatternPointerLo]+y
-	dec y
-	and	a,#$f0
-	or	a,TempBuffer1
-	cmp	a,#$de					;delay sample effect present? if yes, don't trigger sample
-	beq PreTestChannelIsEffectOnly3
-	
-	mov	a,NextRowChFadeOuts
-	or	a,CurrentChannel	;if theres a note in the next row on this channel, set flag to fade it out before the next row gets processed
-	mov	NextRowChFadeOuts,a
-	bra	PreTestChannelIsEffectOnly3
-
-PreTestChannelIsEffectOnly:	
-	inc	y				;if theres a note, the pattern data entry is 4 bytes long
-PreTestChannelIsEffectOnly2:
-	inc	y
-PreTestChannelIsEffectOnly3:	
-	inc	y
-
-PreTestChannelIsVoid:
-	inc	y
-	ret
-
-	
-PatternLoop:
-;get effect value
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y		;get current effect value
-	and	a,#$0f				;and $0f
-	bne	PatternLoopDontSetLoopPoint
-
-;effect value is 0, set loop point:
-	movw	ya,CurrentRowPointerLo	
-	movw	CurrentLoopPointerLo,ya
-	ret
-
-;effect value is not 0, check if we are in an active loop
-PatternLoopDontSetLoopPoint:
-	mov	a,LoopCounter			;check if loop is in progress, must be reset by loop jumper after loop repeat has been finished.
-	and	a,#$20
-	bne	PatternLoopDontSetLoopPointButLoop
-;we arent in a loop, set loop count:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y		;get current effect value
-	and	a,#$0f				;and $0f
-	or	a,#$30				;set "in loop"-flag and "do jump"-flag
-	mov	LoopCounter,a
-	ret
-
-PatternLoopDontSetLoopPointButLoop:
-;we are in a loop, just jump:
-	mov	a,LoopCounter
-	and	a,#$0f
-	dec	a
-	mov	LoopCounter,a
-	beq	PatternLoopFinished
-
-;do another loop jump
-	or	LoopCounter,#$30
-	
-PatternLoopFinished:
-	ret
-
-
-PatternLoopJumper:
-	mov	a,LoopCounter
-	and	a,#%00010000
-	beq	PatternLoopJumperNoJump
-
-	movw	ya,CurrentLoopPointerLo
-	movw	CurrentPatternPointerLo,ya
-	mov	a,LoopCounter		
-	and	a,#%11101111
-	mov	LoopCounter,a
-
-PatternLoopJumperNoJump:
-	ret
-
-EffectNoteRetrigger:
-EffectNoteDelay:
-EffectNoteCutOff:
-	mov	y,#ch_effect_data
-	mov	a,[CurrentChDataLo]+y		;get current effect value
-	and	a,#$0f				;and $0f
-	beq EffectNoteCutOffImmediately
-
-	dec a
-
-EffectNoteCutOffImmediately:
-	mov	y,#ch_tick_delay
-	mov	[CurrentChDataLo]+y,a		;write to buffer
-	ret
-
-TickBasedExEffectNoteCutOff:
-	mov	y,#ch_tick_delay	
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	bne	CheckForTickBasedEffectsNoteCutOffDec
-	
-
-	mov	[CurrentChDataLo]+y,a
-	call	!CutOffChannelGain
-	
-	mov	y,#ch_current_channelmask
-	mov	a,[CurrentChDataLo]+y			;disable channel in keyon reg
-	eor	a,#$ff
-	mov	ScratchPad1,a
-	and	KeyOn,ScratchPad1
-
-	mov	CurrentVolume,#$00
-	call	!SetVolume
-
-	mov	y,#ch_effect_data					;clear effect data so this routine isnt triggered on successive ticks of this frame
-	mov	a,#0
-	mov	[CurrentChDataLo]+y,a
-	
-	ret
-
-
-CheckForTickBasedEffectsNoteCutOffDec:
-	dec a
-	mov	[CurrentChDataLo]+y,a
-	
-;CheckForTickBasedEffectsNoNoteCutOff:
-	ret	
-
-TickBasedExEffectNoteRetrigger:
-TickBasedExEffectNoteDelay:
-	mov	y,#ch_tick_delay
-	mov	a,[CurrentChDataLo]+y
-	and	a,#$0f
-	bne	CheckForTickBasedEffectsNoteDelayDec
-	
-	call	!SetNewSample
-
-	mov	y,#ch_current_channelmask
-	mov	a,[CurrentChDataLo]+y			;enable channel in keyon reg
-	or	a,TickSampleStart
-	mov	TickSampleStart,a
-
-	mov	y,#ch_effect_data					;clear effect data so this routine isnt triggered on successive ticks of this frame
-	mov	a,#0
-	mov	[CurrentChDataLo]+y,a
-	ret
-
-CheckForTickBasedEffectsNoteDelayDec:
-	dec a
-	mov	[CurrentChDataLo]+y,a
-	ret		
-
-SetEchoAndVolume:
-	mov	$f2,#$2c			;echo volume l
-	mov	$f3,#$00			;0d
-	mov	$f2,#$3c			;echo volume r
-	mov	$f3,#$00			;0d
-	mov	$f2,#$4d			;echo channel enable
-	mov	$f3,#$00			;ff
-	ret
-
-ReceiveSongHandler:
-	mov	$f2,#$0c
-	mov	$f3,#$00
-	mov	$f2,#$1c
-	mov	$f3,#$00
-	mov	$f2,#$2c
-	mov	$f3,#$00
-	mov	$f2,#$3c
-	mov	$f3,#$00
-	mov	$f2,#$6c			;disable echo
-	mov	$f3,#$20			
-
-	
-	
-	mov	a,#SpcCmdUploadSong			;set "upload song command received"-flag	so cpu knows we're ready
-	mov	$f4,a
-	mov	a,#$00			;clear remaining ports
-	mov	$f5,a
-	mov	$f6,a
-	mov	$f7,a	
-
-	mov	SpcDataPointerLo,#(ModFile & $00ff)		;setup mod pointer
-	mov	SpcDataPointerHi,#(ModFile >> 8)
-	mov	ModFilePointerLo,#(ModFile & $00ff)		;setup mod pointer
-	mov	ModFilePointerHi,#(ModFile >> 8)
-
-	mov	y,#$00				;clear mod pointer counter(actually, this counter always stays 0,just needed for indirect write)
-
-ReceiveSongWaitLoop2:				;wait for first transfer
-	cmp	$f4,#SpcCmdUploadSongDone
-	beq	ReceiveSongComplete		;check if upload complete
-	
-	cmp	$f4,#SpcCmdUploadSongT1			;check if data for transfer 1 is stable and on ports
-	bne	ReceiveSongWaitLoop2
-
-	mov	a,$f5				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-	mov	a,$f6				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-	mov	a,$f7				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-
-	mov	$f4,#SpcCmdUploadSongT1
-	
-ReceiveSongWaitLoop3:				;wait for second transfer
-	cmp	$f4,#SpcCmdUploadSongT2
-	bne	ReceiveSongWaitLoop3
-
-	mov	a,$f5				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-	mov	a,$f6				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-	mov	a,$f7				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-
-	mov	$f4,#SpcCmdUploadSongT2
-	bra	ReceiveSongWaitLoop2
-
-ReceiveSongComplete:
-	mov	a,#$00			;clear apu ports so that cpu knows were ready
-	mov	$f4,a
-	mov	$f5,a
-	mov	$f6,a
-	mov	$f7,a
-
-	mov	ModTimecode,#0					;clear Timecode
-	mov	ModTimecode+1,#0
-
-	mov	SongEffectsUploaded,#%00000001			;set "song uploaded" flag, clear "sample pack uploaded" flag
-	ret
-
-ReceiveSamplePack:
-	mov	a,#SpcCmdUploadSamplePack			;set "upload song command received"-flag	so cpu knows we're ready
-	mov	$f4,a
-	mov	a,#$00			;clear remaining ports
-	mov	$f5,a
-	mov	$f6,a
-	mov	$f7,a
-	
-	mov	$f2,#$5c			;key off all channels
-	mov	$f3,#%11111111
-	
-	movw	ya,SpcDataPointerLo		;save offset
-	movw	TempBuffer1,ya
-
-	mov	y,#$00				;clear mod pointer counter(actually, this counter always stays 0,just needed for indirect write)
-
-ReceiveSamplePackWaitLoop2:				;wait for first transfer
-	cmp	$f4,#SpcCmdUploadSamplePackDone
-	beq	ReceiveSamplePackComplete		;check if upload complete
-	
-	cmp	$f4,#SpcCmdUploadSongT1			;check if data for transfer 1 is stable and on ports
-	bne	ReceiveSamplePackWaitLoop2
-
-	mov	a,$f5				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-	mov	a,$f6				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-	mov	a,$f7				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-
-	mov	$f4,#SpcCmdUploadSongT1
-	
-ReceiveSamplePackWaitLoop3:				;wait for second transfer
-	cmp	$f4,#SpcCmdUploadSongT2
-	bne	ReceiveSamplePackWaitLoop3
-
-	mov	a,$f5				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-	mov	a,$f6				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-	mov	a,$f7				;get byte
-	mov	[SpcDataPointerLo]+y,a
-	incw	SpcDataPointerLo				;increment counter, word
-
-	mov	$f4,#SpcCmdUploadSongT2
-	bra	ReceiveSamplePackWaitLoop2
-
-ReceiveSamplePackComplete:
-	mov	a,#$00			;clear apu ports so that cpu knows were ready
-	mov	$f4,a
-	mov	$f5,a
-	mov	$f6,a
-	mov	$f7,a
-	movw	ya,TempBuffer1					;restore saved pointer
-	movw	SpcDataPointerLo,ya
-	
-	or	SongEffectsUploaded,#%00000010			;set "sample pack uploaded" flag
-	call	!SetupEffectSamples
-;return to mainloop:
-	jmp	!MainLoop
-
-
-SetupEffectSamples:
-	mov	x,#34*4				;start copying to 34th dsp sample
-	mov	y,#$00
-	mov	a,[SpcDataPointerLo]+y		;get number of sample in pack
-	and	a,#$1f				;maximum number of samples 31
-	mov	TempBuffer1,a			;this is our number of samples to process
-	inc	y				;advance to first byte pointer
-
-SetupEffectSamplesLoop:
-
-;sample adress:
-	mov	a,[SpcDataPointerLo]+y		;get sample relative adress low
-	inc	y
-	clrc
-	adc	a,SpcDataPointerLo		;add modfile position
-	mov		!(SampleSource+0)+x,a		;store in dsp sample area
-	mov	a,[SpcDataPointerLo]+y		;get sample relative adress hi
-	adc	a,SpcDataPointerHi		;add modfile position, with carry from previous add
-	dec	y
-	mov	!(SampleSource+1)+x,a		;store in dsp sample area
-	inc	y
-	inc	y
-;sample loop adress:	
-	mov	a,[SpcDataPointerLo]+y		;get sample relative adress low
-	inc	y
-	clrc
-	adc	a,SpcDataPointerLo		;add modfile position
-	mov		!(SampleSource+2)+x,a		;store in dsp sample area
-	
-	
-	mov	a,[SpcDataPointerLo]+y		;get sample relative adress hi
-	adc	a,SpcDataPointerHi		;add modfile position, with carry from previous add
-	dec	y
-	mov	!(SampleSource+3)+x,a		;store in dsp sample area
-
-	mov	a,y				;increment source pointer by 15 (entry is 16 bytes long)
-	clrc
-	adc	a,#14
-	mov	y,a
-	
-	inc	x
-	inc	x
-	inc	x
-	inc	x
-	dbnz	TempBuffer1,SetupEffectSamplesLoop
-	
-	ret
-
-PlaySoundEffectAbort:
-	jmp	!MainLoop
-
-PlaySoundEffect:
-	movw	ya,$f4				;save all 4 ports to variables
-	movw	TempBuffer1,ya			;tempbuffer1:command,tb2:se number,tb3-4:volume/pitch
-	movw	ya,$f6
-	movw	TempBuffer3,ya
-	
-	mov	$f4,#SpcCmdPlaySoundEffect	;echo command received
-
-
-	
-
-	bbc	$ef.1,PlaySoundEffectAbort		;only process song if song has been uploaded before
-
-	mov	a,TempBuffer4
-	and	a,#$80				;get flip flag
-	eor	a,SoundEffectFlipFlag
-	bne	PlaySoundEffectAbort		;only play effect if this flag has changed as expected
-	
-	eor	SoundEffectFlipFlag,#$80	;toggle flag for next soundeffect
-
-	mov	y,#0
-	mov	a,[SpcDataPointerLo]+y		;get number of samples in pack
-	mov	TempBuffer5,a
-	mov	a,TempBuffer2
-	
-	cmp	a,TempBuffer5
-	bcs	PlaySoundEffectAbort		;return if sound effect to play is bigger than number of samples in pack
-
-
-	mov	a,ActiveSoundEffectCh
-	inc	a				;goto next channel
-	and	a,#3				;maximum number of channels is 3
-	mov	ActiveSoundEffectCh,a		;save back
-	mov	x,a
-	mov	a,!SoundEffectChannelDspRegLUT+x	;get channel value for dsp access
-	mov	TempBuffer5,a
-
-	mov	a,!SoundEffectChannelKofLUT+x	;get channel key off bit
-	mov	TempBuffer6,a
-	mov	$f2,#$5c				;key off current channel
-	mov	$f3,a
-
-	
-;wait 8ms for key off to finish
-	mov	a,$fe	;clear 4bit counter
-	mov	y,#4
-KofWaitLoop2:
-	mov	a,$fe				;wait for 2mS
-	beq	KofWaitLoop2
-	dbnz	y,KofWaitLoop2
-
-	mov	x,TempBuffer5			;get pointer to dsp channel register set
-	
-	mov	a,TempBuffer2			;get sample number
-	asl	a				;multiply by 16
-	asl	a
-	asl	a
-	asl	a
-	inc	a				;increment because first byte in sample pack is number of samples
-	mov	y,a
-	
-	inc	y
-	inc	y
-	inc	y
-	inc	y
-	
-	mov	a,TempBuffer4			;get 65816 command volume
-	and	a,#$7f				;mask off flip flag
-	beq	PlaySoundEffectDefaultVol	
-
-;play SE with custom volume
-	and	a,#%0001111			;get volume
-	mov	TempBuffer7,a
-	clrc
-	asl	a
-	asl	a
-	asl	a
-	and	TempBuffer7,#%00001111		;add lower bits to get maximum range
-	or	a,TempBuffer7
-	mov	TempBuffer7,a
-
-	call	!SoundEffectCalcPanL
-
-	mov	$f2,x
-	mov	$f3,a
-	inc	y
-	inc	x
-	call	!SoundEffectCalcPanR
-	mov	$f2,x
-	mov	$f3,a
-	bra 	PlaySoundEffectCustomVol
-
-PlaySoundEffectDefaultVol:	
-	mov	a,[SpcDataPointerLo]+y		;get volume l
-	
-	mov	$f2,x
-	mov	$f3,a
-	inc	y
-	inc	x
-	mov	a,[SpcDataPointerLo]+y		;get volume r
-	
-	mov	$f2,x
-	mov	$f3,a
-
-PlaySoundEffectCustomVol:
-	inc	y
-	inc	x
-
-	mov	a,TempBuffer3			;get 65816 command pitch
-	beq	PlaySoundEffectDefaultPitch
-
-;play custom pitch. same as mod pitch numbers. valid pitch numbers: 0-59
-	push	y
-;**************************************************
-	asl	a			;asl because each period is 2 bytes long
-	mov	y,a				;get period number
-	mov	a,[PeriodTablePointerLo]+y				;get current period
-	mov	TempBuffer7,a
-	inc	y
-	mov	a,[PeriodTablePointerLo]+y
-	mov	TempBuffer8,a
-
-
-;fetch pitch from pitch table. input: period	
-	mov	y,TempBuffer8		
-	mov	a,TempBuffer7
-	addw	ya,TempBuffer7		;multiply by 2
-	addw	ya,PitchTablePointerLo	;add table offset	
-	movw	TempBuffer7,ya				;move adress to pointer
-	mov	y,#0
-
-	mov	a,[TempBuffer7]+y				;get lo pitch byte	
-	mov	PitchBufferLo,a			;save new pitch
-	inc	y
-	mov	a,[TempBuffer7]+y
-	mov	PitchBufferHi,a
-	pop	y
-	mov	a,PitchBufferLo		;get pitch lo
-	mov	$f2,x
-	mov	$f3,a
-	inc	y
-	inc	x
-	mov	a,PitchBufferHi		;get pitch hi
-	mov	$f2,x
-	mov	$f3,a
-	bra	PlaySoundEffectCustomPitch
-	
-;**********************************************+
-
-
-	
-PlaySoundEffectDefaultPitch:		
-	mov	a,[SpcDataPointerLo]+y		;get pitch lo
-	
-	mov	$f2,x
-	mov	$f3,a
-	inc	y
-	inc	x
-	mov	a,[SpcDataPointerLo]+y		;get pitch hi
-	
-	mov	$f2,x
-	mov	$f3,a
-
-PlaySoundEffectCustomPitch:
-	inc	x
-
-	mov	a,TempBuffer2			;get sound effect to play
-	clrc
-	adc	a,#34				;add 34 (sound effects start at dsp sample 34)
-	
-	mov	$f2,x
-	mov	$f3,a
-
-	inc	y
-	inc	x
-	mov	a,[SpcDataPointerLo]+y		;get adsr lo
-	
-	mov	$f2,x
-	mov	$f3,a
-
-	inc	y
-	inc	x
-	mov	a,[SpcDataPointerLo]+y		;get adsr hi
-	
-	mov	$f2,x
-	mov	$f3,a
-
-	inc	y
-	inc	x
-	mov	a,[SpcDataPointerLo]+y		;get gain
-	
-	mov	$f2,x
-	mov	$f3,a
-
-	mov	$f2,#$5c			;reset key off in case it's still active.(shouldn't, though)
-	mov	$f3,#%00000000
-
-	mov	$f2,#$4c			;key on channel
-	mov	$f3,TempBuffer6
-	
-	jmp	!MainLoop
-
-;in: 	TempBuffer4:volume&pan command
-;	TempBuffer7:total channel volume
-;out:	a,8bit: panned channel volume
-;uses:	TempBuffer8
-
-SoundEffectCalcPanL:
-	mov	a,TempBuffer4			;get pan bits
-	xcn	a				;swap nibbles
-						;put pan bits into lower 4 bits. we're skipping lsr a, asl a here because the pointers in the LUT are words.
-	and	a,#%00000111			;mask off rest
-	push	x
-	asl	a
-	mov	x,a				;use as pointer
-	mov	a,TempBuffer7
-	jmp	[!PlaySoundEffectLVolLUT+x]
-
-
-PlaySoundEffectLVolLUT:
-	.dw PlaySoundEffectVolTBL
-	.dw PlaySoundEffectVolTBL+1
-	.dw PlaySoundEffectVolTBL+2
-	.dw PlaySoundEffectVolTBL+3
-	.dw PlaySoundEffectVolTBL+4
-	.dw PlaySoundEffectVolTBL+5
-	.dw PlaySoundEffectVolTBL+6
-	.dw PlaySoundEffectVolTBL+7
-
-
-SoundEffectCalcPanR:
-	mov	a,TempBuffer4			;get pan bits
-	xcn	a				;swap nibbles
-						;put pan bits into lower 4 bits. we're skipping lsr a, asl a here because the pointers in the LUT are words.
-	and	a,#%00000111			;mask off rest
-	push	x
-	asl	a
-	mov	x,a				;use as pointer
-	mov	a,TempBuffer7
-	jmp	[!PlaySoundEffectRVolLUT+x]
-
-
-PlaySoundEffectRVolLUT:
-	.dw PlaySoundEffectVolTBL+7
-	.dw PlaySoundEffectVolTBL+6
-	.dw PlaySoundEffectVolTBL+5
-	.dw PlaySoundEffectVolTBL+4
-	.dw PlaySoundEffectVolTBL+3
-	.dw PlaySoundEffectVolTBL+2
-	.dw PlaySoundEffectVolTBL+1
-	.dw PlaySoundEffectVolTBL
-			
-PlaySoundEffectVolTBL:
-	lsr	a
-	lsr	a
-	lsr	a
-	lsr	a
-	lsr	a
-	lsr	a
-	lsr	a
-	nop
-	mov	TempBuffer8,a			;save
-	mov	a,TempBuffer7
-	setc
-	sbc	a,TempBuffer8			;substract calculated pan value
-	pop	x
-	ret
-
-ReceiveStream:
-	mov	$f2,#$5c			;key off channels 0-3
-	mov	$f3,#%00001111
-	
-	mov	StreamState,#0			;reset transfer state machine
-	mov	StreamCurrentBuffer,#0		;reset to first buffer
-	
-	call	!SetupStreamSampleAdress
-	movw	ya,$f5
-	movw	TempBuffer1,ya			;get total number of samples to transfer
-	mov	a,#0
-	mov	y,a
-	movw	TempBuffer3,ya			;clear current frame counter
-	movw	$f5,ya				;tell 65816 current frame to transfer
-	mov	$f4,#SpcCmdReceiveStream
-
-ReceiveStreamWaitLoop1:
-	cmp	$f4,#SpcCmdSubmitStreamNumber
-	bne	ReceiveStreamWaitLoop1
-
-
-;wait for desired frame
-	movw	ya,$f5
-	cmpw	ya,TempBuffer3
-	bne	ReceiveStreamRequestFrame
-
-	mov	a,$f7
-	mov	StreamVolume,a
-	beq	ReceiveStreamExit		;exit streaming if volume is 0
-;enter receive state machine
-	mov	a,StreamState
-	asl 	a
-	mov	x,a			;pointer into jump table
-	jmp	[!StreamJumpTable+x]
-	
-ReceiveStreamWaitLoop2:
-	cmp	$f4,#SpcCmdSubmitStreamNumber	;wait for port0 data to change. Don't know if this works out as desired, but 
-	beq	ReceiveStreamWaitLoop2	
-	
-		
-ReceiveStreamTransferLoop:			;66 cycles per scanline. this loop must be exactly 66 bytes long while looping.
-;26 cycles					;59 cycles per scanline left for actual transfer
-
-	movw	ya,$f4				
-	push a					;save data on stack cause that's the fastest way possible
-	push y
-	movw	ya,$f6
-	push a
-	push y
-	
-;waste 33 cyles:
-;******************************
-	mov	a,TempBuffer1			;real snes/bsnes need a total of 33 cycles here
-	mov	a,TempBuffer1
-	mov	a,TempBuffer1
-	mov	a,TempBuffer1
-	mov	a,TempBuffer1
-	mov	a,TempBuffer1
-	mov	a,TempBuffer1
-	mov	a,TempBuffer1
-	mov	a,TempBuffer1
-	mov	a,TempBuffer1
-	mov	a,TempBuffer1
-
-
-
-
-;7 cycles when looping back
-	dbnz	TempBuffer5,ReceiveStreamTransferLoop
-
-	mov	a,#36
-	mov	TempBuffer5,a	
-
-	mov	y,#144-1				;set counter to last byte in buffer(reverse copy because of stack)
-	
-ReceiveStreamSaveLoop:
-	pop a					;dummy loop to fix stack
-	mov	[TempBuffer7]+y,a		;7	-move to buffer
-	dec	y
-	pop a					;dummy loop to fix stack
-	mov	[TempBuffer7]+y,a		;7	-move to buffer
-	dec	y
-	pop a					;dummy loop to fix stack
-	mov	[TempBuffer7]+y,a		;7	-move to buffer
-	dec	y
-	pop a					;dummy loop to fix stack
-	mov	[TempBuffer7]+y,a		;7	-move to buffer
-	dec	y				
-	dbnz	TempBuffer5,ReceiveStreamSaveLoop
-
-	cmp	StreamCurrentBuffer,#SpcStreamLatency
-	bne	SpcStreamDontSetEndBit
-	
-
-	mov	y,#144-9				;set pointer to last samples header
-	mov	a,[TempBuffer7]+y			;get header byte
-	or	a,#%00000011				;set loop	& end bits
-
-	mov	[TempBuffer7]+y,a			;save back header byte
-
-SpcStreamDontSetEndBit:	
-	incw	TempBuffer3			;request next frame
-	inc	StreamCurrentBuffer
-	and	StreamCurrentBuffer,#7				;maximum number of buffers: 8
-StreamTimerWait:				;wait for 16 brr samples to play / ca. 2 frames to pass, then continue downloading stream
-	mov	a,$fd
-	beq	StreamTimerWait
-
-ReceiveStreamRequestFrame:
-	movw	ya,TempBuffer3
-	movw	$f5,ya				;tell 65816 which frame to transfer
-	
-	movw	ya,TempBuffer1			;check if done transfering
-	cmpw	ya,TempBuffer3
-	bne	ReceiveStreamWaitLoop1
-
-ReceiveStreamExit:
-	mov	$f2,#$5c			;key off channels 0-3
-	mov	$f3,#%00000001
-	mov	$f4,#SpcCmdReceiveStreamComplete	;tell 65816 we're done
-
-;StreamWaitSampleEnd:
-	mov	$f1,#$00			;stop timer
-	nop
-	nop
-	mov	$fa,ModPlayerTimer0			;reset timer, return to modplayer
-	
-	nop
-	nop
-	mov	$f1,#$03			;start timer
-	
-	jmp	!MainLoop				;return
-
-
-StreamJumpTable:
-	.dw	InitStream		;fill buffer, then start playing sample
-	.dw	StreamContinue		;fill buffer according to timer
-
-StreamContinue:
-;setup current stream buffer
-	mov	TempBuffer7,#(StreamBuffer & $00ff)		;pointer to first stream buffer
-	mov	TempBuffer8,#(StreamBuffer >> 8)
-	mov	a,StreamCurrentBuffer
-
-	mov	y,#144
-	mul	ya
-	addw	ya,TempBuffer7
-	movw	TempBuffer7,ya			;pointer to current stream buffer in TempBuffer7,8
-
-	mov	a,#$00
-	mov	y,StreamVolume			;update volume
-	movw	$f2,ya
-	inc	a
-	movw	$f2,ya
-
-
-	mov	y,#0				;clear target copy counter
-	
-	mov	a,#36				;amount of scanlines to copy
-	mov	TempBuffer5,a
-	
-	jmp	!ReceiveStreamWaitLoop2
-
-InitStream:
-;receive stream here:
-
-;setup current stream buffer
-	mov	TempBuffer7,#(StreamBuffer & $00ff)		;pointer to first stream buffer
-	mov	TempBuffer8,#(StreamBuffer >> 8)
-	mov	a,StreamCurrentBuffer
-	and	a,#7				;maximum number of buffers: 8
-	mov	y,#144
-	mul	ya
-	addw	ya,TempBuffer7
-	movw	TempBuffer7,ya			;pointer to current stream buffer in TempBuffer7,8
-
-
-	mov	y,#0				;clear target copy counter
-	
-	mov	a,#36				;amount of scanlines to copy
-	mov	TempBuffer5,a
-
-		
-	cmp	StreamCurrentBuffer,#SpcStreamLatency
-	bne	SpcStreamDontStartSample
-
-
-
-
-;setup sample dsp regs on channel 1:
-;wide stereo effect
-	mov	a,#$00
-	mov	y,StreamVolume			;volume
-	movw	$f2,ya
-	inc	a
-	movw	$f2,ya
-	inc	a
-	mov	y,#$00				;pitch lo
-	movw	$f2,ya
-	inc	a
-	mov	y,#$04				;pitch hi
-	movw	$f2,ya
-	inc	a
-	mov	y,#SpcStreamSampleNumber	;sample number
-	movw	$f2,ya
-	inc	a
-	mov	y,#0				;adsr1 (use gain instead)
-	movw	$f2,ya
-	inc	a
-	movw	$f2,ya				;adsr2
-	inc	a
-	mov	y,#$7f				;volume
-	movw	$f2,ya
-
-	mov	$f2,#$5c			;reset key off in case it's still active.(shouldn't, though)
-	mov	$f3,#%00000000
-
-	mov	$f2,#$4c			;key on channel 1
-	mov	$f3,#%00000001
-
-	mov	$f1,#$00			;stop timer
-	nop
-	nop
-	mov	$fa,#StreamerTimer0			;32 milliSeconds on timer 0
-	nop
-	nop
-	mov	$f1,#$03			;start timer
-	inc	StreamState			;goto next state
-
-SpcStreamDontStartSample:		
-	jmp	!ReceiveStreamWaitLoop2
-
-
-
-UpdateVolEchoHandler:
-	mov	ModFilePointerLo,#(MainVolL & $00ff)		;setup mod pointer
-	mov	ModFilePointerHi,#(MainVolL >> 8)
-
-	mov	y,#$00				;clear mod pointer counter(actually, this counter always stays 0,just needed for indirect write)
-	mov	$f4,#$01
-
-
-UpdateVolEchoWaitLoop1:	
-	cmp	$f4,#$00			;check if another data download is due
-	bne	UpdateVolEchoWaitLoop1
-
-	mov	a,$f5				;get byte
-	mov	[ModFilePointerLo]+y,a
-	incw	ModFilePointerLo				;increment counter, word
-	mov	a,$f6				;get byte
-	mov	[ModFilePointerLo]+y,a
-	incw	ModFilePointerLo				;increment counter, word
-	mov	a,$f7				;get byte
-	mov	[ModFilePointerLo]+y,a
-	incw	ModFilePointerLo				;increment counter, word
-
-	mov	$f4,#$00
-
-UpdateVolEchoWaitLoop2:	
-	cmp	$f4,#$01			;check if another data download is due
-	bne	UpdateVolEchoWaitLoop2
-
-	mov	a,$f5				;get byte
-	mov	[ModFilePointerLo]+y,a
-	incw	ModFilePointerLo				;increment counter, word
-	mov	a,$f6				;get byte
-	mov	[ModFilePointerLo]+y,a
-	incw	ModFilePointerLo				;increment counter, word
-	mov	a,$f7				;get byte
-	mov	[ModFilePointerLo]+y,a
-	incw	ModFilePointerLo				;increment counter, word
-
-	mov	a,#$00			;clear apu ports so that cpu knows were ready
-	mov	$f4,a
-	mov	$f5,a
-	mov	$f6,a
-	mov	$f7,a
-UpdateVolEchoVariablesOnly:	
-
-	mov	$f2,#$6d			;echo start adress
-	mov	$f3,#EchoStartAdress			;80
-	mov	$f2,#$7d			;echo delay
-	mov	$f3,#EchoDelay			;06
-	mov	$f2,#$0d			;echo feedback
-	mov	$f3,#$04			;04
-
-
-	mov	$f2,#$0c
-	mov	$f3,MainVolL
-	mov	$f2,#$1c
-	mov	$f3,MainVolR
-	mov	$f2,#$2c
-	mov	$f3,EchoVolL
-	mov	$f2,#$3c
-	mov	$f3,EchoVolR
-	mov	$f2,#$4d
-	mov	$f3,ChannelEchoEnable
-
-	
-	ret
-
-
-
-;set key on/key off here:
-GetDataFromPatternCheckPatternPosition:
-;***********************************************	
-;check if pattern break is due
-	mov	a, PatternBreakFlag					;check if pattern break flag is set
-	beq	CheckPatternBreakExit
-
-	inc	CurrentPatternNumber					;increment current pattern
-	mov	x,CurrentPatternNumber					;check if we overflow
-	cmp	x,NumberOfPatterns
-	bne	PatternBreakNoOverflow
-
-	mov	CurrentPatternNumber,#$00					;reset to pattern #0 if overflow occured
-	mov	x,CurrentPatternNumber
-
-PatternBreakNoOverflow:
-	mov	a,!(ModFile+$fa)+x					;get id number of next pattern
-	asl	a
-	mov	x,a
-	mov	a,!(ModFile+$17a)+x					;get word-pointer to that table
-	mov	y,a
-	mov	a,!(ModFile+$17b)+x
-	addw	ya,InitPatternPointerLo				
-	movw	CurrentPatternPointerLo,ya				;update current pattern pointer
-
-	mov	PatternBreakFlag,#0					;clear pattern break flag and exit
-	pop	a							;need to purge the stack a bit first
-	pop	a							;else, it would overflow slowly when using the pattern break command constantly
-	pop	a
-	pop	a
-	jmp	!MainLoop
-
-CheckPatternBreakExit:
-
-;check if at end of current pattern
-	mov	x,CurrentPatternNumber
-	mov	a,!(ModFile+$fa)+x		;load pattern number
-	inc	a
-	asl	a			;multiply, use as pointer into patterntable pointertable list
-	mov	x,a
-	mov	a,!(ModFile+$17a)+x				;$1455+x	;(ModFile+$17a) ;$17a
-	mov	TempBuffer2,a
-	mov	a,!(ModFile+$17b)+x				;$1456+x	;17b
-	mov	TempBuffer1,a
-	movw	ya,CurrentPatternPointerLo
-	subw	ya,InitPatternPointerLo
-	cmpw	ya,TempBuffer1
-	bpl	CheckPatternPositionPatternEnd
-
-	ret
-
-CheckPatternPositionPatternEnd:
-	inc	CurrentPatternNumber		;increment position in current pattern
-	mov	a,CurrentPatternNumber
-	cmp	a,NumberOfPatterns		;check if at end of pattern
-	beq	CheckPatternPositionReset
-
-	mov	x,a
-	mov	a,!(ModFile+$fa)+x
-	asl	a
-	mov	x,a
-	mov	a,!(ModFile+$17a)+x
-	mov	y,a
-	mov	a,!(ModFile+$17b)+x
-	addw	ya,InitPatternPointerLo
-	movw	CurrentPatternPointerLo,ya
-	movw	CurrentLoopPointerLo,ya
-	ret
-
-CheckPatternPositionReset:				;wrap to pattern 0
-	mov	$f6,#$50
-	mov	CurrentPatternNumber,#$00
-	mov	x,CurrentPatternNumber
-	mov	a,!(ModFile+$fa)+x
-	asl	a
-	mov	x,a
-	mov	a,!(ModFile+$17a)+x
-	mov	y,a
-	mov	a,!(ModFile+$17b)+x
-	addw	ya,InitPatternPointerLo
-	movw	CurrentPatternPointerLo,ya
-	ret
-	
-
-ClearAllChannelArray:
-	mov	a,#(ChannelArray & $ff)		;get pointer to first channel array
-	mov	y,#(ChannelArray	>> 8)
-	movw	TempBuffer1,ya
-	movw	Channel1Array,ya
-	mov	a,#1	
-	call	!ClearChannelArray
-	
-	movw	Channel2Array,ya
-	mov	a,#2
-	call	!ClearChannelArray
-
-	movw	Channel3Array,ya
-	mov	a,#4
-	call	!ClearChannelArray
-
-	movw	Channel4Array,ya
-	mov	a,#8
-	call	!ClearChannelArray		
-	ret
-	
-	
-ClearChannelArray:
-	mov	y,#ch_current_channelmask	;number of bytes to copy
-	mov	[TempBuffer1]+y,a		;put channel mask into array pointer + channel mask value
-	decw	TempBuffer1
-	mov	a,#0
-ClearChannelArrayLoop:
-	mov	[TempBuffer1]+y,a		;clear array
-	dbnz	y,ClearChannelArrayLoop
-	
-	incw	TempBuffer1
-	mov	a,#ch_current_channelmask+1	;get amount of bytes per array and add to current adress
-	mov	y,#0
-	addw	ya,TempBuffer1
-	movw	TempBuffer1,ya			;save adress of next array
-	ret		
-
-CommandVoid:
-	jmp	!MainLoop
-
-SetSongChannelMask:
-	mov		SongChannelMask,$f5			;get new channel mask
-	mov	$f2,#$5c
-	mov	a,SongChannelMask
-	eor	a,#$0f					;invert, switch off masked channels immediately
-	mov	$f3,a					;key off 
-	mov	$f4,#SpcCmdSetSongChMask		;ack
-	jmp	!MainLoop				;return
-
-
-SetSongSpeed:
-	mov	ModPlayerTimer0,$f5			;get new speed
-	
-	mov	$f1,#$00
-	nop
-	nop
-	mov	$fa,ModPlayerTimer0			;20 milliSeconds on timer 0
-	mov	$fb,#$10			;2 milliSeconds on timer 1
-	nop
-	nop
-	mov	$f1,#$03			;start timer(s)	
-	mov	$f4,#SpcCmdSetSongSpeed			;ack
-	jmp	!MainLoop				;return
-
-
-StopSongStream:
-	and	SongEffectsUploaded,#%11111110		;clear "song uploaded" flag
-	mov	$f2,#$5c				;reset key off in case it's still active.(shouldn't, though)
-	mov	$f3,#%00001111				;key off all mod/stream channels
-	mov	$f4,#SpcCmdStopSong			;ack command
-	jmp	!MainLoop				;return
-
-
-
-SetReportType:
-	mov		SpcReportType,$f5			;get new report type
-	mov	$f4,#SpcCmdReportType			;ack
-	jmp	!MainLoop
-
-SetSongVolume:
-	mov		MusicVol1,$f5			;get new volume, mod channel 0,1
-	mov		MusicVol2,$f6			;get new volume, mod channel 0,1
-	mov	$f4,#SpcCmdSetSongVolume			;ack
-	jmp	!MainLoop
-
-SendReportData:
-	mov	a,SpcReportType		;get report type
-	and	a,#$07	
-	asl 	a
-	mov	x,a			;pointer into jump table
-
-	jmp	[!ReportJumpTable+x]
-	
-ReportJumpTable:
-	.dw	ReportVoid
-	.dw	ReportTimecode
-	.dw	ReportChannelLevels
-	.dw	ReportSpecialCmd
-	.dw	ReportVoid
-	.dw	ReportVoid
-	.dw	ReportVoid
-	.dw	ReportVoid
-	
-ReportVoid:
-	mov	a,#0
-	mov	$f5,a			;clear report data
-	mov	$f6,a			
-	mov	$f7,a	
-	ret
-
-
-ReportTimecode:
-	mov	$f5,#0			;clear report byte first
-	movw	ya,ModTimecode
-	movw	$f6,ya
-	mov	a,SpcReportType
-	or	a,#$e0
-	mov	$f5,a			;return report type 
-	ret
-
-
-;report current sample levels of all 4 mod channels as 4bit nibbles unsigned.
-ReportChannelLevels:
-	mov	$f2,#$09
-	mov	a,$f3			;get current wave height ch0
-	lsr	a
-	lsr	a
-	lsr	a
-	and	a,#$0f
-	mov	TempBuffer1,a	
-
-	mov	$f2,#$19
-	mov	a,$f3			;get current wave height ch1
-	asl	a
-	and	a,#$f0
-	or	a,TempBuffer1
-	mov	TempBuffer1,a
-
-	mov	$f2,#$29
-	mov	a,$f3			;get current wave height ch2
-	lsr	a
-	lsr	a
-	lsr	a
-	and	a,#$0f
-	mov	TempBuffer1+1,a	
-
-	mov	$f2,#$39
-	mov	a,$f3			;get current wave height ch3
-	asl	a
-	and	a,#$f0
-	or	a,TempBuffer1+1
-	mov	TempBuffer1+1,a				
-	
-	movw	ya,TempBuffer1
-	
-	mov	$f5,#0			;clear report byte first
-	movw	$f6,ya			;write data to ports
-	mov	a,SpcReportType
-	or	a,#$e0
-	mov	$f5,a			;return report type 
-	ret	
-
-ReportSpecialCmd:
-	mov	$f5,#0			;clear report byte first
-	mov	a,SpecialReportCmd
-	mov	$f6,a
-	mov	a,SpcReportType
-	or	a,#$e0
-	mov	$f5,a			;return report type 
-	ret
-	
-	
-SoundEffectChannelDspRegLUT:
-	.db	$40
-	.db	$50
-	.db	$60
-	.db	$70
-
-SoundEffectChannelKofLUT:
-	.db	$10
-	.db	$20
-	.db	$40
-	.db	$80
-		
-VibratoTable:
-	.incbin "data/apu/vibratotable.tbl"
-
-PeriodTable:
-	.include "data/apu/amigaperiodtable.tbl"
-
-PitchTable:
-	.include "data/apu/pitchtable_new.tbl"
-	.incbin "data/apu/pitchtable2.tbl"
-ModFile:

BIN
snes/loader/data/apu/pitchtable2.tbl


+ 0 - 860
snes/loader/data/apu/pitchtable_new.tbl

@@ -1,860 +0,0 @@
-.dw 0		;added for great justice. neccesary?
-.dw 0
-.dw 0
-.dw 0
-.dw 0
-.dw 0
-.dw 0
-.dw 0
-.dw 63447
-.dw 55515
-.dw 49346
-.dw 44411
-.dw 40373
-.dw 37008
-.dw 34161
-.dw 31720
-.dw 29605
-.dw 27754
-.dw 26121
-.dw 24669
-.dw 23371
-.dw 22202
-.dw 21144
-.dw 20183
-.dw 19305
-.dw 18500
-.dw 17760
-.dw 17077		;42b5
-
-/*
-.dw 16444		;403c 1st
-.dw 15856		;3df0
-.dw 15309		;3bcd
-.dw 14799
-.dw 14321
-.dw 13873
-.dw 13453
-.dw 13057
-.dw 12684
-.dw 12331
-.dw 11998
-.dw 11682
-.dw 11382
-.dw 11097
-.dw 10826		;2a4a
-.dw 10568		;2948
-.dw 10323		;2853
-.dw 10088		;2768
-.dw 9863		;2687
-.dw 9649		;25b1
-.dw 9443
-.dw 9247
-.dw 9058
-.dw 8876
-.dw 8702
-.dw 8535
-.dw 8374
-.dw 8218
-.dw 8069
-.dw 7925
-.dw 7785
-.dw 7651
-.dw 7521
-.dw 7396
-.dw 7274
-.dw 7157
-.dw 7043
-.dw 6933
-.dw 6826
-.dw 6723
-.dw 6622
-.dw 6525
-.dw 6430
-.dw 6338
-.dw 6249
-.dw 6162
-.dw 6077
-.dw 5995
-.dw 5915
-.dw 5837
-.dw 5761
-.dw 5687
-.dw 5615
-.dw 5545
-.dw 5476
-.dw 5410
-.dw 5344
-.dw 5281
-.dw 5218
-.dw 5158
-.dw 5098
-.dw 5040
-.dw 4984
-.dw 4928
-.dw 4874
-.dw 4821
-.dw 4769
-.dw 4718
-.dw 4668
-.dw 4620
-.dw 4572
-.dw 4525
-.dw 4479
-.dw 4435
-.dw 4391
-.dw 4347
-.dw 4305
-.dw 4264
-.dw 4223
-.dw 4183
-.dw 4144
-.dw 4106
-.dw 4068
-.dw 4031
-.dw 3994
-.dw 3959
-.dw 3924
-.dw 3889
-.dw 3855
-.dw 3822
-.dw 3789
-.dw 3757
-.dw 3725
-.dw 3694
-.dw 3664
-.dw 3634
-.dw 3604
-.dw 3575
-.dw 3546
-.dw 3518
-.dw 3490
-.dw 3463
-.dw 3436
-.dw 3410
-.dw 3383
-.dw 3358
-.dw 3332
-.dw 3308
-.dw 3283
-.dw 3259
-.dw 3235
-.dw 3211
-.dw 3188
-.dw 3165
-.dw 3143
-.dw 3121
-.dw 3099
-.dw 3077
-.dw 3056
-.dw 3035
-.dw 3014
-.dw 2994
-.dw 2974
-.dw 2954
-.dw 2934
-.dw 2915
-.dw 2896
-.dw 2877
-.dw 2858
-.dw 2840
-.dw 2822
-.dw 2804
-.dw 2786
-.dw 2769
-.dw 2752
-.dw 2735
-.dw 2718
-.dw 2701
-.dw 2685
-.dw 2669
-.dw 2652
-.dw 2637
-.dw 2621
-.dw 2606
-.dw 2590
-.dw 2575
-.dw 2560
-.dw 2545
-.dw 2531
-.dw 2516
-.dw 2502
-.dw 2488
-.dw 2474
-.dw 2460
-.dw 2447
-.dw 2433
-.dw 2420
-.dw 2407
-.dw 2394
-.dw 2381
-.dw 2368
-.dw 2355
-.dw 2343
-.dw 2331
-.dw 2318
-.dw 2306
-.dw 2294
-.dw 2282
-.dw 2271
-.dw 2259
-.dw 2247
-.dw 2236
-.dw 2225
-.dw 2214
-.dw 2203
-.dw 2192
-.dw 2181
-.dw 2170
-.dw 2159
-.dw 2149
-.dw 2139
-.dw 2128
-.dw 2118
-.dw 2108
-.dw 2098
-.dw 2088
-.dw 2078
-.dw 2068
-.dw 2059
-.dw 2049
-.dw 2040
-.dw 2030
-.dw 2021
-.dw 2012
-.dw 2003
-.dw 1994
-.dw 1985
-.dw 1976
-.dw 1967
-.dw 1958
-.dw 1949
-.dw 1941
-.dw 1932
-.dw 1924
-.dw 1916
-.dw 1907
-.dw 1899
-.dw 1891
-.dw 1883
-.dw 1875
-.dw 1867
-.dw 1859
-.dw 1851
-.dw 1843
-.dw 1836
-.dw 1828
-.dw 1821
-.dw 1813
-.dw 1806
-.dw 1798
-.dw 1791
-.dw 1784
-.dw 1777
-.dw 1769
-.dw 1762
-.dw 1755
-.dw 1748
-.dw 1741
-.dw 1735
-.dw 1728
-.dw 1721
-.dw 1714
-.dw 1708
-.dw 1701
-.dw 1695
-.dw 1688
-.dw 1682
-.dw 1675
-.dw 1669
-.dw 1663
-.dw 1656
-.dw 1650
-.dw 1644
-.dw 1638
-.dw 1632
-.dw 1626
-.dw 1620
-.dw 1614
-.dw 1608
-.dw 1602
-.dw 1596
-.dw 1590
-.dw 1585
-.dw 1579
-.dw 1573
-.dw 1568
-.dw 1562
-.dw 1557
-.dw 1551
-.dw 1546
-.dw 1540
-.dw 1535
-.dw 1530
-.dw 1524
-.dw 1519
-.dw 1514
-.dw 1509
-.dw 1504
-.dw 1498
-.dw 1493
-.dw 1488
-.dw 1483
-.dw 1478
-.dw 1473
-.dw 1468
-.dw 1464
-.dw 1459
-.dw 1454
-.dw 1449
-.dw 1444
-.dw 1440
-.dw 1435
-.dw 1430
-.dw 1426
-.dw 1421
-.dw 1416
-.dw 1412
-.dw 1407
-.dw 1403
-.dw 1398
-.dw 1394
-.dw 1390
-.dw 1385
-.dw 1381
-.dw 1376
-.dw 1372
-.dw 1368
-.dw 1364
-.dw 1359
-.dw 1355
-.dw 1351
-.dw 1347
-.dw 1343
-.dw 1339
-.dw 1335
-.dw 1331
-.dw 1327
-.dw 1323
-.dw 1319
-.dw 1315
-.dw 1311
-.dw 1307
-.dw 1303
-.dw 1299
-.dw 1295
-.dw 1292
-.dw 1288
-.dw 1284
-.dw 1280
-.dw 1276
-.dw 1273
-.dw 1269
-.dw 1265
-.dw 1262
-.dw 1258
-.dw 1255
-.dw 1251
-.dw 1247
-.dw 1244
-.dw 1240
-.dw 1237
-.dw 1233
-.dw 1230
-.dw 1227
-.dw 1223
-.dw 1220
-.dw 1216
-.dw 1213
-.dw 1210
-.dw 1206
-.dw 1203
-.dw 1200
-.dw 1196
-.dw 1193
-.dw 1190
-.dw 1187
-.dw 1184
-.dw 1180
-.dw 1177
-.dw 1174
-.dw 1171
-.dw 1168
-.dw 1165
-.dw 1162
-.dw 1159
-.dw 1156
-.dw 1152
-.dw 1149
-.dw 1146
-.dw 1143
-.dw 1140
-.dw 1138
-.dw 1135
-.dw 1132
-.dw 1129
-.dw 1126
-.dw 1123
-.dw 1120
-.dw 1117
-.dw 1114
-.dw 1112
-.dw 1109
-.dw 1106
-.dw 1103
-.dw 1100
-.dw 1098
-.dw 1095
-.dw 1092
-.dw 1089
-.dw 1087
-.dw 1084
-.dw 1081
-.dw 1079
-.dw 1076
-.dw 1073
-.dw 1071
-.dw 1068
-.dw 1066
-.dw 1063
-.dw 1060
-.dw 1058
-.dw 1055
-.dw 1053
-.dw 1050
-.dw 1048
-.dw 1045
-.dw 1043
-.dw 1040
-.dw 1038
-.dw 1035
-.dw 1033
-.dw 1031
-.dw 1028
-.dw 1026
-.dw 1023
-.dw 1021
-.dw 1019
-.dw 1016
-.dw 1014
-.dw 1011
-.dw 1009
-.dw 1007
-.dw 1005
-.dw 1002
-.dw 1000
-.dw 998
-.dw 995
-.dw 993
-.dw 991
-.dw 989
-.dw 986
-.dw 984
-.dw 982
-.dw 980
-.dw 978
-.dw 975
-.dw 973
-.dw 971
-.dw 969
-.dw 967
-.dw 965
-.dw 963
-.dw 960
-.dw 958
-.dw 956
-.dw 954
-.dw 952
-.dw 950
-.dw 948
-.dw 946
-.dw 944
-.dw 942
-.dw 940
-.dw 938
-.dw 936
-.dw 934
-.dw 932
-.dw 930
-.dw 928
-.dw 926
-.dw 924
-.dw 922
-.dw 920
-.dw 918
-.dw 916
-.dw 914
-.dw 912
-.dw 910
-.dw 909
-.dw 907
-.dw 905
-.dw 903
-.dw 901
-.dw 899
-.dw 897
-.dw 896
-.dw 894
-.dw 892
-.dw 890
-.dw 888
-.dw 886
-.dw 885
-.dw 883
-.dw 881
-.dw 879
-.dw 878
-.dw 876
-.dw 874
-.dw 872
-.dw 871
-.dw 869
-.dw 867
-.dw 865
-.dw 864
-.dw 862
-.dw 860
-.dw 859
-.dw 857
-.dw 855
-.dw 854
-.dw 852
-.dw 850
-.dw 849
-.dw 847
-.dw 845
-.dw 844
-.dw 842
-.dw 840
-.dw 839
-.dw 837
-.dw 836
-.dw 834
-.dw 832
-.dw 831
-.dw 829
-.dw 828
-.dw 826
-.dw 825
-.dw 823
-.dw 821
-.dw 820
-.dw 818
-.dw 817
-.dw 815
-.dw 814
-.dw 812
-.dw 811
-.dw 809
-.dw 808
-.dw 806
-.dw 805
-.dw 803
-.dw 802
-.dw 800
-.dw 799
-.dw 797
-.dw 796
-.dw 794
-.dw 793
-.dw 792
-.dw 790
-.dw 789
-.dw 787
-.dw 786
-.dw 784
-.dw 783
-.dw 782
-.dw 780
-.dw 779
-.dw 778
-.dw 776
-.dw 775
-.dw 773
-.dw 772
-.dw 771
-.dw 769
-.dw 768
-.dw 767
-.dw 765
-.dw 764
-.dw 763
-.dw 761
-.dw 760
-.dw 759
-.dw 757
-.dw 756
-.dw 755
-.dw 753
-.dw 752
-.dw 751
-.dw 749
-.dw 748
-.dw 747
-.dw 746
-.dw 744
-.dw 743
-.dw 742
-.dw 741
-.dw 739
-.dw 738
-.dw 737
-.dw 736
-.dw 734
-.dw 733
-.dw 732
-.dw 731
-.dw 729
-.dw 728
-.dw 727
-.dw 726
-.dw 724
-.dw 723
-.dw 722
-.dw 721
-.dw 720
-.dw 719
-.dw 717
-.dw 716
-.dw 715
-.dw 714
-.dw 713
-.dw 711
-.dw 710
-.dw 709
-.dw 708
-.dw 707
-.dw 706
-.dw 705
-.dw 703
-.dw 702
-.dw 701
-.dw 700
-.dw 699
-.dw 698
-.dw 697
-.dw 696
-.dw 694
-.dw 693
-.dw 692
-.dw 691
-.dw 690
-.dw 689
-.dw 688
-.dw 687
-.dw 686
-.dw 685
-.dw 684
-.dw 682
-.dw 681
-.dw 680
-.dw 679
-.dw 678
-.dw 677
-.dw 676
-.dw 675
-.dw 674
-.dw 673
-.dw 672
-.dw 671
-.dw 670
-.dw 669
-.dw 668
-.dw 667
-.dw 666
-.dw 665
-.dw 664
-.dw 663
-.dw 662
-.dw 661
-.dw 660
-.dw 659
-.dw 658
-.dw 657
-.dw 656
-.dw 655
-.dw 654
-.dw 653
-.dw 652
-.dw 651
-.dw 650
-.dw 649
-.dw 648
-.dw 647
-.dw 646
-.dw 645
-.dw 644
-.dw 643
-.dw 642
-.dw 641
-.dw 640
-.dw 639
-.dw 638
-.dw 637
-.dw 636
-.dw 636
-.dw 635
-.dw 634
-.dw 633
-.dw 632
-.dw 631
-.dw 630
-.dw 629
-.dw 628
-.dw 627
-.dw 626
-.dw 625
-.dw 625
-.dw 624
-.dw 623
-.dw 622
-.dw 621
-.dw 620
-.dw 619
-.dw 618
-.dw 617
-.dw 617
-.dw 616
-.dw 615
-.dw 614
-.dw 613
-.dw 612
-.dw 611
-.dw 611
-.dw 610
-.dw 609
-.dw 608
-.dw 607
-.dw 606
-.dw 605
-.dw 605
-.dw 604
-.dw 603
-.dw 602
-.dw 601
-.dw 600
-.dw 600
-.dw 599
-.dw 598
-.dw 597
-.dw 596
-.dw 595
-.dw 595
-.dw 594
-.dw 593
-.dw 592
-.dw 591
-.dw 591
-.dw 590
-.dw 589
-.dw 588
-.dw 587
-.dw 587
-.dw 586
-.dw 585
-.dw 584
-.dw 583
-.dw 583
-.dw 582
-.dw 581
-.dw 580
-.dw 579
-.dw 579
-.dw 578
-.dw 577
-.dw 576
-.dw 576
-.dw 575
-.dw 574
-.dw 573
-.dw 573
-.dw 572
-.dw 571
-.dw 570
-.dw 570
-.dw 569
-.dw 568
-.dw 567
-.dw 567
-.dw 566
-.dw 565
-.dw 564
-.dw 564
-.dw 563
-.dw 562
-.dw 561
-.dw 561
-.dw 560
-.dw 559
-.dw 559
-.dw 558
-.dw 557
-.dw 556
-.dw 556
-.dw 555
-.dw 554
-.dw 554
-.dw 553
-.dw 552
-.dw 551
-.dw 551
-.dw 550
-.dw 549
-.dw 549
-.dw 548
-.dw 547
-.dw 547
-.dw 546
-.dw 545
-.dw 545
-.dw 544
-.dw 543
-.dw 542
-.dw 542
-.dw 541
-.dw 540
-.dw 540
-.dw 539
-.dw 538
-.dw 538
-.dw 537
-.dw 536
-.dw 536
-.dw 535
-.dw 534
-.dw 534
-.dw 533
-.dw 532
-.dw 532
-.dw 531
-.dw 530
-.dw 530
-.dw 529
-.dw 529
-.dw 528
-.dw 527
-.dw 527
-.dw 526
-.dw 525
-.dw 525
-.dw 524
-.dw 523
-.dw 523
-.dw 522
-.dw 522
-.dw 521
-.dw 520
-.dw 520
-.dw 519
-.dw 518
-.dw 518
-.dw 517
-.dw 517
-.dw 516
-.dw 515
-.dw 515
-.dw 514
-.dw 513
-.dw 513
-.dw 512
-*/

BIN
snes/loader/data/apu/vibratotable.tbl


BIN
snes/loader/data/battle_sky.clr


BIN
snes/loader/data/blanktile.pic


BIN
snes/loader/data/cpuusage.clr


BIN
snes/loader/data/cpuusage.pic


+ 0 - 1
snes/loader/data/font/asciitablejap.tbl

@@ -1 +0,0 @@
-PUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUP蟅Q訰送课W仗研世谅媚牌侨梢覛湜U郀、¥ウЖ┆���辈炒刀犯節S瀘熗€亗儎厗噲墛媽崕彁憭摂晼棙櫩衔覷U沀U歎UUUUUUUU篣UUUU淯UUU患UUUUUUUUUUTU肿刭谲圯扪夯冀綳YZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~VWUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU

BIN
snes/loader/data/font/font1.pic


BIN
snes/loader/data/font/font1pal.clr


BIN
snes/loader/data/sounds/hit.brr


+ 0 - 2
snes/loader/linkfile

@@ -1,2 +0,0 @@
-[objects]
-main.o

+ 0 - 310
snes/loader/main.asm

@@ -1,310 +0,0 @@
-.MEMORYMAP
-DEFAULTSLOT 0
-SLOTSIZE $10000
-SLOT 0 $0000
-.ENDME
-
-
-.ROMBANKSIZE $10000    ; Every ROM bank is 64 KBytes in size, also necessary.
-.HIROM
-.ROMBANKS 4
-
-.DEFINE HEADER_OFF $8000
-.COMPUTESNESCHECKSUM
-.EMPTYFILL $ff
-
-	.include "routines/variables.asm"
-	.include "routines/defines.asm"
-
-
-;***********************************************************************************
-; setup header
-;***********************************************************************************
-.define BaseAdress		$c00000
-
-
-;includes with superfree sections go here:
-	.include "routines/miscdata.asm"
-	.include "routines/bgmodes.asm"
-;	.include "routines/battlefiles.asm"
-;	.include "routines/battlezscrolllists.asm"
-;	.include "routines/battlezscrolllut.asm"
-;	.include "routines/introscene3scrolltable.asm"
-	.include "routines/oamvectoranglelut.asm"
-	.include "routines/oamobjects.asm"
-	.include "routines/oamanimationlists.asm"
-;	.include "routines/hdmatables.asm"
-	.include "routines/menufiles.asm"	
-	.include "routines/textstrings.asm"
-	.include "routines/spritedata.asm"
-	.include "routines/songs.asm"
-	.include "routines/samplepacks.asm"
-	.include "routines/backgroundfiles.asm"
-;	.include "routines/videoframes.asm"
-
-;includes with fixed sections go here:	
-	.include "routines/audiostreams.asm"
-;	.include "routines/levelfiles.asm"	
-
-.BANK 0 SLOT 0	; The SLOT 0 may be ommitted, as SLOT 0 is the DEFAULTSLOT
-; === Cartridge Header - part 1 - =====================
-.ORG    $7FC0 + HEADER_OFF
-.DB     "OPTIXX TESTROM       "     ; Title (can't be more than 21 bytes, and should probably be a full 21 bytes)
-
-;       "123456789012345678901"
-.ORG    $7FD5 + HEADER_OFF
-.DB     $31                         ; Memory Mode   ( $20 = Slow LoRom, $21 = Slow HiRom )
-
-.BANK 0 SLOT 0
-; === Cartridge Header - part 2 - =====================
-.ORG    $7FD6 + HEADER_OFF
-.DB     $00                   ; Contents ( $00 = ROM only, $01 = ROM and RAM, $02 = ROM and Save RAM)
-.DB     $08                  ; ROM Size   ( $08 = 2 Mbit, $09 = 4 Mbit, $0A = 8Mbit, $0B = 16Mbit c=32, d=64... etc )
-.DB     $00                   ; SRAM Size ( $00 = 0 bits, $01 = 16 kbits, $02 = 32 kbits, $03 = 64 kbits )
-.DB     $01                   ; Country ( $01 = USA )
-.DB     $33                   ; Licensee Code
-.DB     $01                   ; Version
-.dw		$0						;checksum
-.dw		$ffff					;checksum xor. this must be filled out here, else wla dx thinks its free space, places something there and overwrites it with the checksum later.
-
-.BANK 0 SLOT 0
-; === Interrupt Vector Table ====================
-.ORG    $7FE4 + HEADER_OFF   ; === Native Mode ===
-.DW     EmptyHandler          ; COP
-.DW     EmptyHandler          ; BRK
-.DW     EmptyHandler          ; ABORT
-.DW     NmiHookUp                ; NMI
-.DW     $0000                 ; (Unused)
-.DW     IrqHookUp          ; IRQ
-
-.ORG    $7FF4 + HEADER_OFF   ; === Emulation Mode ===
-.DW     EmptyHandler          ; COP
-.DW     $0000                 ; (Unused)
-.DW     EmptyHandler          ; ABORT
-.DW     EmptyHandler          ; NMI
-.DW     Boot           ; RESET
-.DW     EmptyHandler          ; IRQ/BRK
-
-; ============================================
-
-
-	
-
-.bank 0 slot 0
-.org $ffa0
-EmptyHandler:
-	rti
-
-Boot:
-	SEI
-	CLC
-	XCE
-	PHK
-	PLB
-	REP #$30
-	SEP #$20
-	STZ $4200		;reg $4200  - disable timers, NMI,and auto-joyread
-	lda #%00000001
-	sta $420d		;set memory mode to fastrom
-	jml (HiromStart+BaseAdress) 		;lorom
-
-NmiHookUp:
-	rti
-IrqHookUp:
-	jml (IrqLoader+BaseAdress)
-
-
-
-.bank 0 slot 0
-.org $0
-.Section "Main Code"
-;functions to include go here:
-	.include "routines/printstring.asm"
-	.include "routines/menusystem.asm"
-	.include "routines/gfxvrammisc.asm"
-	.include "routines/vblanknmi.asm"
-;	.include "routines/levelloader.asm"
-;	.include "routines/bgscrolling.asm"
-	.include "routines/dmafifo.asm"
-	.include "routines/irq.asm"
-	.include "routines/oammanager.asm"
-	.include "routines/oamsubroutines.asm"
-;	.include "routines/collisiondetection.asm"
-	.include "routines/randomnumbergen.asm"
-;	.include "routines/hdmahandler.asm"
-;	.include "routines/hdmasubroutines.asm"
-	.include "routines/spcinterface.asm"
-	.include "routines/menusubroutines.asm"
-;	.include "routines/videoplayer.asm"
-	.include "routines/memoryclear.asm"
-	.include "routines/eventroutines.asm"
-	.include "routines/joypadread.asm"	
-
-
-HiromStart:
-	sep #$20
-	LDA #$80
-	STA $2100		;turn screen off for now, zero brightness
-
-	rep #$31
-	lda.w #$0000
-	tcd
-
-	lda.w #$01ff
-	tcs
-
-	sep #$20
-	lda.b #0		;clear word: $0000
-	ldy.w #$1f0
-	ldx.w #0
-	jsr ClearWRAM
-
-	lda.b #0		;clear word: $0000
-	ldy.w #$6000
-	ldx.w #$200
-	jsr ClearWRAM
-
-	LDX #$2101
-
-MemClearLoop1:		;regs $2101-$210C
-	STZ $00,X		;set Sprite,Character,Tile sizes to lowest, and set addresses to $0000
-	INX
-	CPX #$210D
-	BNE MemClearLoop1
-
-MemClearLoop2:		;regs $210D-$2114
-	STZ $00,X		;Set all BG scroll values to $0000
-	STZ $00,X
-	INX
-	CPX #$2115
-	BNE MemClearLoop2
-	
-	LDA #$80		;reg $2115
-	STA $2115		; Initialize VRAM transfer mode to word-access, increment by 1
-	STZ $2116		;regs $2117-$2117
-	STZ $2117		;VRAM address = $0000
-	STZ $211A		;clear Mode7 setting
-	LDX #$211B
-
-MemClearLoop3:		;regs $211B-$2120
-	STZ $00,X		;clear out the Mode7 matrix values
-	STZ $00,X
-	INX
-	CPX #$2121
-	BNE MemClearLoop3
-	LDX #$2123
-
-MemClearLoop4:		;regs $2123-$2133
-	STZ $00,X		;turn off windows, main screens, sub screens, color addition,
-	INX			;fixed color = $00, no super-impose (external synchronization),
-	CPX #$2134		;no interlaced mode, normal resolution
-	BNE MemClearLoop4
-	
-	LDA #$FF
-	STA $4201		;reg $4201  - programmable I/O write port, initalize to allow reading at in-port
-	nop
-	nop
-	LDA $4210		;reg $4210  - NMI status, reading resets
-	lda $4211		;irq status reset
-
-;clear all graphics buffers:
-	jsr ClearPalette   ;Reset colors
-	jsr ClearPaletteBuffer
-	jsr ClearBg1TilemapBuffer
-	jsr ClearBg2TilemapBuffer
-	jsr InitDmaFifo
-	jsr InitOam
-	jsr ClearColObjList
-	jsr ClearZBuffer
-;init variables:
-	rep #$31
-	lda.w #$1234			;seed RNG
-	sta.b R1
-	lda.w #$55aa
-	sta.b R2
-
-	sep #$20
-	lda #%00000001		;enable screen, auto joypad
-	sta.w InterruptEnableFlags
-	sta.w $4200
-	lda.w SetIni			;set display mode 
-	sta.w $2133			;dont set this during nmi cause if the overscan flag is changed mid-nmi, it might result in screw ups with the nmi timing
-	cli
-	jsr ROMToWRAM
-    jml (go+$7f0000)
-go:
-    jsr EnableScreen
-    jsr SpcPlaySong
-/*		
-;main loop starts here:
-CheckNextFrame:
-	ldx.w FrameCounterLo	;load current frame counter
-	cpx.w LastFrameLo	;load last frame processed
-	beq CheckNextFrame	;check until one frame advances
-	stx.w LastFrameLo
-*/
-
-;main loop starts here:
-CheckNextFrame:
-
-	lda.w $4210				;wait until out of nmi
-	bmi CheckNextFrame
-
-CheckNextNMI:	
-	lda.w $4210				;wait until in nmi
-	bpl CheckNextNMI
-	
-	jsr NMI
-
-	lda CurrentEvent		;load number of currently active scene
-	asl				;multiply number by 2
-	rep #$31			;set accu to 16bit
-	and.w #$00ff			;only use low byte
-	tax				;transfer to x
-	
-	sep #$20			;reset accu to 8bit
-	lda.w SetIni			;set display mode
-	sta.l $2133			;dont set this during nmi cause if the overscan flag is changed mid-nmi, it might result in screw ups with the nmi timing
-
-
-	php
-	jsr (EventPtTable,x)	;and jump to the location found at pointertable where x is the pointernumber
-	plp
-	lda.b #$80
-	sta.l $4201
-	nop
-	nop
-	nop
-	nop
-	lda.l $2137
-	lda.l $213f			;reset $213d to low byte
-	lda.l $213d			;get current scanline
-	sta.w CpuUsageScanline 
-	bra CheckNextFrame
-
-
-.ends
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

+ 0 - 50
snes/loader/makefile

@@ -1,50 +0,0 @@
-# 65816 stuff
-AC = wla-65816
-AFLAGS = -o
-LD = wlalink
-LDFLAGS = -vsr
-FL = snesflash
-FLFLAGS = -wf
-UCON = ucon64
-UCONFLAGS = --port=usb --xsnesram
-SFILES  = main.asm
-OFILES  = $(SFILES:.asm=.o)
-ROMFILE = main.smc
-EMU = zsnes
-# spc stuff
-SPCAC = wla-spc700
-SPCSFILES  = data/apu/apucode.asm
-SPCOFILES  = $(SPCSFILES:.asm=.o)
-SPCFILE = $(SPCSFILES:.asm=.bin)
-
-
-all: spc $(OFILES) 
-	$(LD) $(LDFLAGS) linkfile $(ROMFILE)
-	dd if=$(ROMFILE) bs=1 count=65544 of=rom.smc
-	python conv_rle.py 
-	cp -v loader.[ch] ../../avr/usbload
-
-$(OFILES): $(SFILES)
-	$(AC) $(AFLAGS) $(SFILES)
-
-spc: $(SPCOFILES)
-	$(LD) -vsb spclinkfile $(SPCFILE)
-
-$(SPCOFILES): $(SPCSFILES)
-	$(SPCAC) $(AFLAGS) $(SPCSFILES)
-
-header:
-	$(UCON) -smc $(ROMFILE)
-
-flash:
-	$(FL) $(FLFLAGS) $(ROMFILE)
-
-upload: header
-	$(UCON) $(UCONFLAGS) $(ROMFILE)
-run:
-	$(EMU) $(ROMFILE)
-
-clean:
-	rm -f $(ROMFILE) rom.smc $(SPCFILE) core *~ *.o *.sym *.srm data/apu/*.o data/apu/*.sym loader.c loader.h main.bak
-
-

+ 0 - 4
snes/loader/routines/audiostreams.asm

@@ -1,4 +0,0 @@
-.Section "AudiostreamLUT" superfree				
-StreamSetLut:
-.db 0
-.ends

+ 0 - 22
snes/loader/routines/backgroundfiles.asm

@@ -1,22 +0,0 @@
-
-.Section "BackgroundfileLUT" superfree	
-UploadBackgroundFileLUT:
-	.dw BackgroundFile0 & $ffff
-	.db (:BackgroundFile0 + BaseAdress>>16)
-.ends
-
-.Section "background file 0" superfree
-;battlefile 0 sky	
-BackgroundFile0:
-	.dw BackgroundFile0Tiles-BackgroundFile0
-	.dw BackgroundFile0Tilemap-BackgroundFile0
-	.dw BackgroundFile0Palette-BackgroundFile0
-	.dw BackgroundFile0EOF-BackgroundFile0
-BackgroundFile0Tiles:
-;	.incbin "data/battle_sky.pic"
-BackgroundFile0Tilemap:
-;	.incbin "data/battle_sky.map"
-BackgroundFile0Palette:
-	.incbin "data/battle_sky.clr" READ 32		;only get a single 16color palette
-BackgroundFile0EOF:
-.ends

+ 0 - 272
snes/loader/routines/bgmodes.asm

@@ -1,272 +0,0 @@
-.Section "BGmode" superfree
-BgModeLut:
-	.dw BgModeTable0
-	.dw BgModeTable1
-	.dw BgModeTable2
-	.dw BgModeTable3
-	.dw BgModeTable4
-	.dw BgModeTable5
-	.dw BgModeTable6
-	.dw BgModeTable7
-	.dw BgModeTable8
-
-
-;normal mode1 16color background mode. debug menu
-BgModeTable0:
-	.db $00				;00	SetIni		Hires screen settings 			(reg $2133)
-	.db %00001001				;01	ScreenMode	screen mode/bg tilesize/bg3 priority 	(reg $2105)
-	.db %00010100			;02	MainScreen	mainscreen designation 			(reg $212c)
-	.db %00000000			;03	SubScreen	subscreen designation 			(reg $212d)
-	.db %00000000				;04	CGWsel		color add/sub settings 		(reg $2130)
-	.db %00111111				;05	CgadsubConfig	color add/sub settings 2 	(reg $2131)
-	.db $25				;06	BGTilesVram12	bg1/bg2 tile base adress 		(reg $210b)
-	.db $01				;07	BGTilesVram34	bg3/bg4 tile base adress 		(reg $210c)
-	.db $00				;08	BG1TilemapVram	bg1 screen size and tilemap base adress (reg $2107)
-	.db $08				;09	BG2TilemapVram	bg2 screen size and tilemap base adress (reg $2107)
-	.db $10				;10	BG3TilemapVram	bg3 screen size and tilemap base adress (reg $2107)
-	.db $18				;11	BG4TilemapVram	bg4 screen size and tilemap base adress (reg $2107)
-	.db %00100011			;12	ObjSel		Sprite size, name and base adress 	(reg $2101)
-	.db $00				;13	IrqRoutineNumber number of irq routine to use. 0 means irq disabled
-	.db %00000000			;14	W12SEL		$2123 window enable/inverse bg1,2
-	.db $00				;15	W34SEL		$2124 window enable/inverse bg3,4
-	.db %00100000			;16	WOBJSEL		$2125 window enable/inverse obj/col
-	.db 1				;17	W1L		$2126 window 1 left pos
-	.db 0				;18	W1R		$2127 window 1 right pos
-	.db $00				;19	W2L		$2128 window 2 left pos
-	.db $00				;20	W2R		$2129 window 2 right pos
-	.db %00000000			;21	WBGLOG		$212a window mask logic bg
-	.db $00				;22	WOBJLOG		$212b window mask logic obj/col
-	.db %00000000			;23	WMS		$212e window main screen designation
-	.db %00000000			;24	WSS		$212f window sub screen designation
-
-;normal levels. player select, battle level, results screen
-;mode3 256color level mode with overscan and irq cutoff for dma transfers with sprites. sprites=8x8 + 32x32
-BgModeTable1:
-	.db %00000100			;00	SetIni		Hires/overscan screen settings 		(reg $2133)
-	.db $03				;01	ScreenMode	screen mode/bg tilesize/bg3 priority 	(reg $2105)
-	.db %00010001			;02	MainScreen	mainscreen designation 			(reg $212c)
-	.db %00010001			;03	SubScreen	subscreen designation 			(reg $212d)
-	.db %10100000			;04	CGWsel		color add/sub settings 			(reg $2130)
-	.db $00				;05	CgadsubConfig	color add/sub settings 2 		(reg $2131)
-	.db $70				;06	BGTilesVram12	bg1/bg2 tile base adress 		(reg $210b)
-	.db $00				;07	BGTilesVram34	bg3/bg4 tile base adress 		(reg $210c)
-	.db $5c				;08	BG1TilemapVram	bg1 screen size and tilemap base adress (reg $2107)
-	.db $7c				;09	BG2TilemapVram	bg2 screen size and tilemap base adress (reg $2107)
-	.db $00				;10	BG3TilemapVram	bg3 screen size and tilemap base adress (reg $2107)
-	.db $00				;11	BG4TilemapVram	bg4 screen size and tilemap base adress (reg $2107)
-	.db %00100011			;12	ObjSel		Sprite size, name and base adress 	(reg $2101)
-	.db $01				;13	IrqRoutineNumber number of irq routine to use. 0 means irq disabled
-	.db %00000011			;14	W12SEL		$2123 window enable/inverse bg1,2
-	.db $00				;15	W34SEL		$2124 window enable/inverse bg3,4
-	.db %00000011			;16	WOBJSEL		$2125 window enable/inverse obj/col
-	.db 16				;17	W1L		$2126 window 1 left pos
-	.db 239				;18	W1R		$2127 window 1 right pos
-	.db $00				;19	W2L		$2128 window 2 left pos
-	.db $00				;20	W2R		$2129 window 2 right pos
-	.db %00000000			;21	WBGLOG		$212a window mask logic bg
-	.db $00				;22	WOBJLOG		$212b window mask logic obj/col
-	.db %00010001			;23	WMS		$212e window main screen designation
-	.db %00000000			;24	WSS		$212f window sub screen designation
-
-;battles	
-;mode3 256color level mode with overscan and irq cutoff for dma transfers with sprites. sprites=8x8 + 32x32
-BgModeTable2:
-	.db %00000100			;00	SetIni		Hires/overscan screen settings 		(reg $2133)
-	.db $03				;01	ScreenMode	screen mode/bg tilesize/bg3 priority 	(reg $2105)
-	.db %00010011			;02	MainScreen	mainscreen designation 			(reg $212c)
-	.db %00010011			;03	SubScreen	subscreen designation 			(reg $212d)
-	.db %10100000			;04	CGWsel		color add/sub settings 			(reg $2130)
-	.db $00				;05	CgadsubConfig	color add/sub settings 2 		(reg $2131)
-	.db $40				;06	BGTilesVram12	bit0-3:bg1/bit4-7:bg2 tile base adress	(reg $210b)
-	.db $00				;07	BGTilesVram34	bg3/bg4 tile base adress 		(reg $210c)
-	.db %1011001			;08	BG1TilemapVram	bg1 screen size and tilemap base adress (reg $2107)
-	.db %111100			;09	BG2TilemapVram	bg2 screen size and tilemap base adress (reg $2107)
-	.db $00				;10	BG3TilemapVram	bg3 screen size and tilemap base adress (reg $2107)
-	.db $00				;11	BG4TilemapVram	bg4 screen size and tilemap base adress (reg $2107)
-	.db %00100011			;12	ObjSel		Sprite size, name and base adress 	(reg $2101)
-	.db $01				;13	IrqRoutineNumber number of irq routine to use. 0 means irq disabled
-	.db %00110011			;14	W12SEL		$2123 window enable/inverse bg1,2
-	.db $00				;15	W34SEL		$2124 window enable/inverse bg3,4
-	.db %00110011			;16	WOBJSEL		$2125 window enable/inverse obj/col
-	.db 16				;17	W1L		$2126 window 1 left pos
-	.db 239				;18	W1R		$2127 window 1 right pos
-	.db $00				;19	W2L		$2128 window 2 left pos
-	.db $00				;20	W2R		$2129 window 2 right pos
-	.db %00000000			;21	WBGLOG		$212a window mask logic bg
-	.db $00				;22	WOBJLOG		$212b window mask logic obj/col
-	.db %00010011			;23	WMS		$212e window main screen designation
-	.db %00000000			;24	WSS		$212f window sub screen designation
-
-;intro scene 2, moon with corona
-;mode3 256color level mode with overscan and irq cutoff for dma transfers with sprites. sprites=8x8 + 64x64
-BgModeTable3:
-	.db %00000100			;00	SetIni		Hires/overscan screen settings 		(reg $2133)
-	.db $03				;01	ScreenMode	screen mode/bg tilesize/bg3 priority 	(reg $2105)
-	.db %00010000			;02	MainScreen	mainscreen designation 			(reg $212c)
-	.db %00010001			;03	SubScreen	subscreen designation 			(reg $212d)
-	.db %00000010			;04	CGWsel		color add/sub settings 			(reg $2130)
-	.db %00110001			;05	CgadsubConfig	color add/sub settings 2 		(reg $2131)
-	.db $00				;06	BGTilesVram12	bg1/bg2 tile base adress 		(reg $210b)
-	.db $00				;07	BGTilesVram34	bg3/bg4 tile base adress 		(reg $210c)
-	.db $5c				;08	BG1TilemapVram	bg1 screen size and tilemap base adress (reg $2107)
-	.db $00				;09	BG2TilemapVram	bg2 screen size and tilemap base adress (reg $2107)
-	.db $00				;10	BG3TilemapVram	bg3 screen size and tilemap base adress (reg $2107)
-	.db $00				;11	BG4TilemapVram	bg4 screen size and tilemap base adress (reg $2107)
-	.db %01000011			;12	ObjSel		Sprite size, name and base adress 	(reg $2101)
-	.db $01				;13	IrqRoutineNumber number of irq routine to use. 0 means irq disabled
-	.db %00000011			;14	W12SEL		$2123 window enable/inverse bg1,2
-	.db $00				;15	W34SEL		$2124 window enable/inverse bg3,4
-	.db %00000011			;16	WOBJSEL		$2125 window enable/inverse obj/col
-	.db 16				;17	W1L		$2126 window 1 left pos
-	.db 239				;18	W1R		$2127 window 1 right pos
-	.db $00				;19	W2L		$2128 window 2 left pos
-	.db $00				;20	W2R		$2129 window 2 right pos
-	.db %00000000			;21	WBGLOG		$212a window mask logic bg
-	.db $00				;22	WOBJLOG		$212b window mask logic obj/col
-	.db %00010001			;23	WMS		$212e window main screen designation
-	.db %00010001			;24	WSS		$212f window sub screen designation
-
-;titlescreen	
-;mode3 256color level mode with overscan and irq cutoff for dma transfers with sprites. sprites=8x8 + 32x32
-BgModeTable4:
-	.db %00000100			;00	SetIni		Hires/overscan screen settings 		(reg $2133)
-	.db $03				;01	ScreenMode	screen mode/bg tilesize/bg3 priority 	(reg $2105)
-	.db %00010011			;02	MainScreen	mainscreen designation 			(reg $212c)
-	.db %00010011			;03	SubScreen	subscreen designation 			(reg $212d)
-	.db %10100000			;04	CGWsel		color add/sub settings 			(reg $2130)
-	.db %10100001				;05	CgadsubConfig	color add/sub settings 2 		(reg $2131)
-	.db $50				;06	BGTilesVram12	bit0-3:bg1/bit4-7:bg2 tile base adress	(reg $210b)
-	.db $00				;07	BGTilesVram34	bg3/bg4 tile base adress 		(reg $210c)
-	.db %01011100			;08	BG1TilemapVram	bg1 screen size and tilemap base adress (reg $2107)
-	.db %01001100			;09	BG2TilemapVram	bg2 screen size and tilemap base adress (reg $2107)
-	.db $00				;10	BG3TilemapVram	bg3 screen size and tilemap base adress (reg $2107)
-	.db $00				;11	BG4TilemapVram	bg4 screen size and tilemap base adress (reg $2107)
-	.db %01000011			;12	ObjSel		Sprite size, name and base adress 	(reg $2101)
-	.db $01				;13	IrqRoutineNumber number of irq routine to use. 0 means irq disabled
-	.db %00110011			;14	W12SEL		$2123 window enable/inverse bg1,2
-	.db $00				;15	W34SEL		$2124 window enable/inverse bg3,4
-	.db %00110011			;16	WOBJSEL		$2125 window enable/inverse obj/col
-	.db 16				;17	W1L		$2126 window 1 left pos
-	.db 239				;18	W1R		$2127 window 1 right pos
-	.db $00				;19	W2L		$2128 window 2 left pos
-	.db $00				;20	W2R		$2129 window 2 right pos
-	.db %00000000			;21	WBGLOG		$212a window mask logic bg
-	.db $00				;22	WOBJLOG		$212b window mask logic obj/col
-	.db %00010011			;23	WMS		$212e window main screen designation
-	.db %00000000			;24	WSS		$212f window sub screen designation
-	
-;normal mode1 16color background mode. gra logo
-BgModeTable5:
-	.db $00				;00	SetIni		Hires screen settings 			(reg $2133)
-	.db %00001001				;01	ScreenMode	screen mode/bg tilesize/bg3 priority 	(reg $2105)
-	.db %00010001			;02	MainScreen	mainscreen designation 			(reg $212c)
-	.db %00000000			;03	SubScreen	subscreen designation 			(reg $212d)
-	.db %00000000				;04	CGWsel		color add/sub settings 		(reg $2130)
-	.db %00110011				;05	CgadsubConfig	color add/sub settings 2 	(reg $2131)
-	.db $25				;06	BGTilesVram12	bg1/bg2 tile base adress 		(reg $210b)
-	.db $01				;07	BGTilesVram34	bg3/bg4 tile base adress 		(reg $210c)
-	.db $00				;08	BG1TilemapVram	bg1 screen size and tilemap base adress (reg $2107)
-	.db $08				;09	BG2TilemapVram	bg2 screen size and tilemap base adress (reg $2107)
-	.db $10				;10	BG3TilemapVram	bg3 screen size and tilemap base adress (reg $2107)
-	.db $18				;11	BG4TilemapVram	bg4 screen size and tilemap base adress (reg $2107)
-	.db %01000011			;12	ObjSel		Sprite size, name and base adress 	(reg $2101)
-	.db $01				;13	IrqRoutineNumber number of irq routine to use. 0 means irq disabled
-	.db %00000000			;14	W12SEL		$2123 window enable/inverse bg1,2
-	.db $00				;15	W34SEL		$2124 window enable/inverse bg3,4
-	.db %00100000			;16	WOBJSEL		$2125 window enable/inverse obj/col
-	.db 1				;17	W1L		$2126 window 1 left pos
-	.db 0				;18	W1R		$2127 window 1 right pos
-	.db $00				;19	W2L		$2128 window 2 left pos
-	.db $00				;20	W2R		$2129 window 2 right pos
-	.db %00000000			;21	WBGLOG		$212a window mask logic bg
-	.db $00				;22	WOBJLOG		$212b window mask logic obj/col
-	.db %00000000			;23	WMS		$212e window main screen designation
-	.db %00000000			;24	WSS		$212f window sub screen designation
-
-
-;titlescreen flash	
-;mode3 256color level mode with overscan and irq cutoff for dma transfers with sprites. sprites=8x8 + 32x32
-BgModeTable6:
-	.db %00000100			;00	SetIni		Hires/overscan screen settings 		(reg $2133)
-	.db $03				;01	ScreenMode	screen mode/bg tilesize/bg3 priority 	(reg $2105)
-	.db %00010011			;02	MainScreen	mainscreen designation 			(reg $212c)
-	.db %00010011			;03	SubScreen	subscreen designation 			(reg $212d)
-	.db %10100000			;04	CGWsel		color add/sub settings 			(reg $2130)
-	.db %00111111				;05	CgadsubConfig	color add/sub settings 2 		(reg $2131)
-	.db $50				;06	BGTilesVram12	bit0-3:bg1/bit4-7:bg2 tile base adress	(reg $210b)
-	.db $00				;07	BGTilesVram34	bg3/bg4 tile base adress 		(reg $210c)
-	.db %01011100			;08	BG1TilemapVram	bg1 screen size and tilemap base adress (reg $2107)
-	.db %01001100			;09	BG2TilemapVram	bg2 screen size and tilemap base adress (reg $2107)
-	.db $00				;10	BG3TilemapVram	bg3 screen size and tilemap base adress (reg $2107)
-	.db $00				;11	BG4TilemapVram	bg4 screen size and tilemap base adress (reg $2107)
-	.db %01000011			;12	ObjSel		Sprite size, name and base adress 	(reg $2101)
-	.db $01				;13	IrqRoutineNumber number of irq routine to use. 0 means irq disabled
-	.db %00110011			;14	W12SEL		$2123 window enable/inverse bg1,2
-	.db $00				;15	W34SEL		$2124 window enable/inverse bg3,4
-	.db %00110011			;16	WOBJSEL		$2125 window enable/inverse obj/col
-	.db 16				;17	W1L		$2126 window 1 left pos
-	.db 239				;18	W1R		$2127 window 1 right pos
-	.db $00				;19	W2L		$2128 window 2 left pos
-	.db $00				;20	W2R		$2129 window 2 right pos
-	.db %00000000			;21	WBGLOG		$212a window mask logic bg
-	.db $00				;22	WOBJLOG		$212b window mask logic obj/col
-	.db %00010011			;23	WMS		$212e window main screen designation
-	.db %00000000			;24	WSS		$212f window sub screen designation	
-
-;16 color videos, 256 cc background 64x32 bg1
-BgModeTable7:
-	.db $00				;00	SetIni		Hires screen settings 			(reg $2133)
-	.db %00001011				;01	ScreenMode	screen mode/bg tilesize/bg3 priority 	(reg $2105)
-	.db %00010011			;02	MainScreen	mainscreen designation 			(reg $212c)
-	.db %00000000			;03	SubScreen	subscreen designation 			(reg $212d)
-	.db %00000000				;04	CGWsel		color add/sub settings 		(reg $2130)
-	.db %00110011				;05	CgadsubConfig	color add/sub settings 2 	(reg $2131)
-	.db $12				;06	BGTilesVram12	bg1/bg2 tile base adress 		(reg $210b)
-	.db $00				;07	BGTilesVram34	bg3/bg4 tile base adress 		(reg $210c)
-	.db $01				;08	BG1TilemapVram	bg1 screen size and tilemap base adress aaaaaayx (reg $2107)
-	.db $0c				;09	BG2TilemapVram	bg2 screen size and tilemap base adress (reg $2107)
-	.db $00				;10	BG3TilemapVram	bg3 screen size and tilemap base adress (reg $2107)
-	.db $00				;11	BG4TilemapVram	bg4 screen size and tilemap base adress (reg $2107)
-	.db %00100011			;12	ObjSel		Sprite size, name and base adress 	(reg $2101)
-	.db $01				;13	IrqRoutineNumber number of irq routine to use. 0 means irq disabled
-	.db %00000000			;14	W12SEL		$2123 window enable/inverse bg1,2
-	.db $00				;15	W34SEL		$2124 window enable/inverse bg3,4
-	.db %00100000			;16	WOBJSEL		$2125 window enable/inverse obj/col
-	.db 1				;17	W1L		$2126 window 1 left pos
-	.db 0				;18	W1R		$2127 window 1 right pos
-	.db $00				;19	W2L		$2128 window 2 left pos
-	.db $00				;20	W2R		$2129 window 2 right pos
-	.db %00000000			;21	WBGLOG		$212a window mask logic bg
-	.db $00				;22	WOBJLOG		$212b window mask logic obj/col
-	.db %00000000			;23	WMS		$212e window main screen designation
-	.db %00000000			;24	WSS		$212f window sub screen designation	
-	
-;16 color videos, 256 cc background 32x32 bg1, credits
-BgModeTable8:
-	.db $00				;00	SetIni		Hires screen settings 			(reg $2133)
-	.db %00001011				;01	ScreenMode	screen mode/bg tilesize/bg3 priority 	(reg $2105)
-	.db %00010011			;02	MainScreen	mainscreen designation 			(reg $212c)
-	.db %00000000			;03	SubScreen	subscreen designation 			(reg $212d)
-	.db %00000000				;04	CGWsel		color add/sub settings 		(reg $2130)
-	.db %00110011				;05	CgadsubConfig	color add/sub settings 2 	(reg $2131)
-	.db $12				;06	BGTilesVram12	bg1/bg2 tile base adress 		(reg $210b)
-	.db $00				;07	BGTilesVram34	bg3/bg4 tile base adress 		(reg $210c)
-	.db $00				;08	BG1TilemapVram	bg1 screen size and tilemap base adress aaaaaayx (reg $2107)
-	.db $0c				;09	BG2TilemapVram	bg2 screen size and tilemap base adress (reg $2107)
-	.db $00				;10	BG3TilemapVram	bg3 screen size and tilemap base adress (reg $2107)
-	.db $00				;11	BG4TilemapVram	bg4 screen size and tilemap base adress (reg $2107)
-	.db %01000011			;12	ObjSel		Sprite size, name and base adress 	(reg $2101)
-	.db $01				;13	IrqRoutineNumber number of irq routine to use. 0 means irq disabled
-	.db %00000000			;14	W12SEL		$2123 window enable/inverse bg1,2
-	.db $00				;15	W34SEL		$2124 window enable/inverse bg3,4
-	.db %00100000			;16	WOBJSEL		$2125 window enable/inverse obj/col
-	.db 1				;17	W1L		$2126 window 1 left pos
-	.db 0				;18	W1R		$2127 window 1 right pos
-	.db $00				;19	W2L		$2128 window 2 left pos
-	.db $00				;20	W2R		$2129 window 2 right pos
-	.db %00000000			;21	WBGLOG		$212a window mask logic bg
-	.db $00				;22	WOBJLOG		$212b window mask logic obj/col
-	.db %00000000			;23	WMS		$212e window main screen designation
-	.db %00000000			;24	WSS		$212f window sub screen designation		
-	
-.ends	

+ 0 - 255
snes/loader/routines/defines.asm

@@ -1,255 +0,0 @@
-;*************************************************************************
-.define DEBUG			1			;enable debugmenu
-;*************************************************************************
-
-;*************************************************************************
-;spc interface definitions:
-.define  SpcFrameSize		144
-.define	 SpcFramesPerBank	455	
-
-.define SpcCmdUploadSong	$f1		;indicates that a song is to be uploaded
-.define SpcCmdUploadSongT1	$f2		;indicates that data for transfer1 is on apu ports
-.define SpcCmdUploadSongT2	$f3		;indicates that data for transfer2 is on apu ports
-.define SpcCmdUploadSongDone	$f4		;indicates that song upload is complete
-.define SpcCmdReceiveStream	$f5		;indicates that 65816 wants to stream brr data to spc
-.define SpcCmdSubmitStreamNumber	$f7		;indicates that hdma transfer has started.  It's important that bit0 of this command is set.(brr end bit)
-.define SpcCmdReceiveStreamComplete	$f6	;spc wants to end stream transmission.
-.define SpcCmdUploadSamplePack	$f8		;indicates that a sample pack is to be uploaded. the rest of the commands are taken from normal song upload
-.define SpcCmdUploadSamplePackDone	$f9		;indicates that sample pack upload is complete
-.define SpcCmdPlaySoundEffect	$fa		;play a sound effect
-.define SpcCmdStopSong		$fb		;stop song or stream
-.define SpcCmdSetSongSpeed	$fc		;set timer speed of mod playback routine
-.define SpcCmdSetSongChMask	$fd		;song channel mask
-.define SpcCmdReportType	$fe		;type of data spc should respond with
-
-.define SpcScanlineWaitCount	5		;amount of scanlines to wait before frame send
-
-;spc fifo commands for other routines to write to
-.define SpcFifoCmdUploadSong	$02		;arg 0 is song number
-.define SpcFifoCmdUploadSamplePack	$04		;arg 0 is song number
-.define SpcFifoCmdStreamBrr	$06		;arg 0 is stream frameset number
-.define SpcFifoCmdPlaySE	$08		;arg 0 is stream frameset number
-.define SpcFifoCmdStopSong	$0a		;arg 0 is stream frameset number
-.define SpcFifoCmdSetSpeed	$0c		;arg 0 is speed
-.define SpcFifoCmdSetChMask	$0e		;arg 0 is mask
-.define SpcFifoCmdSetReportType	$10		;arg 0 is mask
-;*************************************************************************
-
-;*************************************************************************
-;background settings
-.define FontVramOffset		$2500	;$2800	;vram offset of the font, starting tile index is $180
-.define FontTileConfig			$20	;priority bit set, tiles $100+, palette 1
-
-.define TileBufferSizeX	28		;number of tiles in tilebuffer per x-line
-.define TileBufferSizeY	26		;number of tiles in tilebuffer per y-line
-
-.define TileMapSizeX	31		;number of tiles in tilebuffer per x-line
-.define TileMapSizeY	31		;number of tiles in tilebuffer per y-line
-;*************************************************************************
-
-
-;*************************************************************************
-;fifo buffer entry definitions:
-.define DmaFifoEntryLength	8	;length of an entry in the dma fifo buffer
-.define DmaFifoEntryType	DmaFifoBuffer &$ffff + $7e0000
-.define DmaFifoEntryCount	DmaFifoBuffer &$ffff + $7e0000+1
-.define DmaFifoEntryTarget	DmaFifoBuffer &$ffff + $7e0000+3
-.define DmaFifoEntrySrcLo	DmaFifoBuffer &$ffff + $7e0000+5
-.define DmaFifoEntrySrcHi	DmaFifoBuffer &$ffff + $7e0000+6
-.define DmaFifoEntrySrcBank	DmaFifoBuffer &$ffff + $7e0000+7
-
-.define DmaFifoBytesPerFrame	$1000-$220-$200-$200		;substract oam and cgram transfer sizes
-.define DmaFifoMinTransferSize	128
-;*************************************************************************
-
-
-
-;*************************************************************************
-;object buffer entry definitions:
-.define ObjectFileSize	32
-.define ObjEntryType			ObjectList & $ffff		;0 object type designation
-													;bit0=X position sign of sprite(usually 0)
-													;bit1=Object size flag
-													;bit2=collidable
-													;bit3=subroutine? if set, this object has its own subroutine that must be executed every frame
-													;bit4=animate? if set, this object is animated(a special table for each object specifies the exact animation with commands for tileloading, waiting, animation loop etc)
-													;bit5=bg-bound? if set, this object must move in accordance with background layer 0
-													;bit6=object active? if set, this object is active and needs to be drawn. if clear, this sprite doesnt need to be drawn, but must be processed, anyway
-													;bit7=object present? if set, this slot has an object. if clear, its considered empty and can be overwritten
-.define ObjEntryType2			ObjectList & $ffff + 1	;extra type definitions. msb set=pseudo-3d sprite that has to be moved when scrolling.
-													;bit7=pseudo 3d sprite that needs to be moved according to z-value when background moves
-													;bit6=don't upload tiles for this sprite. useful for stuff like particles and such where lots of sprites share the same tiles.
-													;bit5=don't upload palette for this sprite.
-													;bit4=decaying gravity sprite
-													;bits0-3: current position in vector angle LUT (didn't fit anywhere else)
-													
-.define ObjEntrySubRout			ObjectList & $ffff + 2
-.define ObjEntryTileset			ObjectList & $ffff + 3
-.define ObjEntryTilesetFrame	ObjectList & $ffff + 4
-.define ObjEntryVramTile		ObjectList & $ffff + 5	;vram tile and
-.define ObjEntryPalConf			ObjectList & $ffff + 6	;pal config must be in that order because they are accessed word-wise together
-.define ObjEntryXPos			ObjectList & $ffff + 7	;word size
-.define ObjEntryYPos			ObjectList & $ffff + 9	;word size
-.define ObjEntryAniFrame		ObjectList & $ffff + 11
-.define ObjEntryAniList			ObjectList & $ffff + 12
-.define ObjEntryListOffset		ObjectList & $ffff + 13
-.define ObjEntryPalNumber		ObjectList & $ffff + 14
-.define ObjEntryObjectNumber	ObjectList & $ffff + 15	;number of object type so other routines know what object the`re dealing with. this is not the number of the object in the lookup table, but an arbitrary number that defines certain object types/groups so they can be moved/deleted alltogether.
-.define ObjEntryXDisplacement	ObjectList & $ffff + 17	;used only by obj2oam writer to center objects
-.define ObjEntryYDisplacement	ObjectList & $ffff + 18	;used only by obj2oam writer to center objects
-.define ObjEntryZDisplacement	ObjectList & $ffff + 19	;used to calculate priority. also used as direct z-value in pseudo-3d scenes.
-.define ObjEntryAniCmdRepeat	ObjectList & $ffff + 20	;used by animation list processor. allows repeated nops with a single command
-.define ObjEntryColliSub		ObjectList & $ffff + 21	;subroutine to execute when mainchara hits this object(only active if object is collidable)
-
-.define ObjEntryVectorSpeed		ObjectList & $ffff + 22	;bit0-2:subpixel speed. bit3-5:pixel speed.  bit7 set: target speed met  
-.define ObjEntryVectorTarSpeed	ObjectList & $ffff + 23	;bit0-2:subpixel speed target. bit3-5:pixel speed target. bit6,7: movement type(direct, linear slow, linear fast, smooth)
-.define ObjEntryVectorDir		ObjectList & $ffff + 24	;bit0-5:direction.0=facing up. bit6=turning direction.(set=clockwise) msb set=target direction met.
-.define ObjEntryVectorTarDir	ObjectList & $ffff + 25	;bit0-5:target direction.0=facing up.  bit6,7: movement type(direct, linear slow, linear fast, smooth)
-.define ObjEntryVectorTurnSpeed	ObjectList & $ffff + 26	;bit0-2:vector speed subpixel buffer. bit3-7: direction turn speed sub-pixel buffer. 
-
-
-.define ObjEntryXSpeed				ObjectList & $ffff + 22	;byte, gets added to x-pos every frame. lower 4bit subpixel precision
-.define ObjEntryYSpeed				ObjectList & $ffff + 23	;word, gets added to y-pos every frame. lower 4bit subpixel precision. needs to be word because of +/- handling and gravity
-.define ObjEntryGravity				ObjectList & $ffff + 25	;byte, gets added to y-speed every frame.
-.define ObjEntryLifeCounter		ObjectList & $ffff + 26	;word, decreased every frame
-
-.define ObjEntrySpareVar		ObjectList & $ffff + 27	;5 bytes of data that can be used as a variable depending on the objects needs. for example, npcs uses this to store direction and walk count
-
-;.define MaxGravObjCount	20											;maximum amount of allowed particles onscreen
-
-;zsort buffer definitions:
-.define OamZSortBufferSize 6				;entries:
-							;0	- sprite x
-							;1	- sprite y
-							;2	- sprite config
-							;3	- sprite config
-							;4	- size/sign bits (bit0,1) bit7 clear: sprite present flag
-							;5	- z priority (scanline number)
-							
-.define SpriteTileSizeX	8		;pixel size of one tile for sprite processor
-.define SpriteTileSizeY	8		;pixel size of one tile for sprite processor
-
-;*************************************************************************
-
-
-
-;*************************************************************************
-;exit & collision definitions
-.define ExitFileSize	8
-.define ExitTargetMap		ExitList & $ffff 
-.define ExitSubroutine		ExitList & $ffff +1	;bit 7 indicates that an exit is present and is masked off when jumping. it can conveniently be checked by loading the first word and checking for the sign flag
-.define ExitXPosition		ExitList & $ffff +2
-.define ExitYPosition		ExitList & $ffff +3
-.define ExitXTargetPosition		ExitList & $ffff +4
-.define ExitYTargetPosition		ExitList & $ffff +5
-
-;collidable objects definitions
-.define ColObjFileSize	6
-.define ColObjNumber		ColObjList & $ffff	;object number in object list
-.define ColObjEnableFlagsSub	ColObjList & $ffff +1	;msb is enable flag, lower 7 bits are subroutine number
-;.define ColObjSubroutine	ColObjList & $ffff +2
-.define ColObjXPos		ColObjList & $ffff +2	;xpos/8
-.define ColObjYPos		ColObjList & $ffff +4	;ypos/8
-
-.define NumberOfCollidableObjects	32			;how far to check into object array to find collidable objects. slows down object processor alot when many people are walking
-;*************************************************************************
-
-
-;*************************************************************************
-;hdma buffer definitions
-.define HdmaBufferTableEntry	HdmaBuffer & $ffff
-.define HdmaBufferFlags				HdmaBuffer & $ffff +1
-.define HdmaBufferBBusTarget	HdmaBuffer & $ffff +2
-.define HdmaBufferWriteConfig	HdmaBuffer & $ffff +3
-.define HdmaBufferRomDataTbl	HdmaBuffer & $ffff +4
-.define HdmaBufferRomCountTbl	HdmaBuffer & $ffff +5
-.define HdmaBufferSubRout	HdmaBuffer & $ffff +6	
-.define HdmaBufferRamDataPnt	HdmaBuffer & $ffff +7	;2 bytes
-.define HdmaBufferRamCountPnt	HdmaBuffer & $ffff +9	;2 bytes
-.define HdmaBufferEntryPnt	HdmaBuffer & $ffff +11	;2 bytes simple relative pointer to hdma table in ram to speed up processing
-.define HdmaBufferRomDataPnt	HdmaBuffer & $ffff +13	;3 bytes
-.define HdmaBufferRomDataLength	HdmaBuffer & $ffff +16	;3 bytes
-.define HdmaBufferRomCountPnt	HdmaBuffer & $ffff +19	;3 bytes
-.define HdmaBufferTable		HdmaBuffer & $ffff +24	;start of actual table
-
-.define HdmaBufferSize		$340
-.define HdmaEffectFileSize	6			;size of a hdma effect file in rom
-.define HdmaBufferNumber	6
-
-.define Hdma3dScrollLineNumber	80	;number of lines to process for this effect.
-;*************************************************************************
-
-
-;*************************************************************************
-;Textbox menu definitions:
-.define TextBoxMenuSubrout	TextBoxMenuBuffer & $ffff	;uses same subroutines as script commands
-.define TextBoxMenuFlags	TextBoxMenuBuffer & $ffff + 1
-.define TextBoxMenuParam1	TextBoxMenuBuffer & $ffff + 2
-.define TextBoxMenuParam2	TextBoxMenuBuffer & $ffff + 3
-.define TextBoxMenuParam3	TextBoxMenuBuffer & $ffff + 4
-.define TextBoxMenuTilePos	TextBoxMenuBuffer & $ffff + 5	;x-pixelposition inside buffer
-.define TextBoxMenuLinePos	TextBoxMenuBuffer & $ffff + 6	;y-pixelposition inside buffer
-.define TextBoxMenuVoid		TextBoxMenuBuffer & $ffff + 7	;future expansion
-
-.define TextBoxMenuEntrySize	8
-;*************************************************************************
-
-
-;*************************************************************************
-;script commands ($00-$1f)
-.define StringEnd		0	;end string and close textbox immediately
-.define StringBreak		1
-.define StringCls		2
-.define StringButtonCls		3
-.define StringFontChng		4	;takes one additional byte
-.define StringEndButton		5	;wait for button press, then end string and close textbox
-.define StringMenuEntry		6	;create menu entry. takes 4 parameters
-.define StringMenuWait		7	;wait for button press/menu decision
-.define StringLoadString	8	;immediately clear screen and load another textstring. takes 2 parameters(15bit textstring number)
-.define StringLoadLevel		9	;immediately clear screen and load another level. takes 3 parameter(8bit level number, 8bit x-pos, 8bit y-pos target/8)
-.define StringPlaySong		10	;upload & play a mod song. arg0: song number
-.define StringGotoBattle	11	;goto battle mode. arg0: battle number arg1: event routine to load after returning from battle. arg2,3: vwf string to load after returning from battle. 0=don't load any textstring at all 
-.define StringGotoSubstring	12	;goto substring, returnable, can be nested 16 times. arg0,1: string number(word)
-.define StringSubstringReturn	13	;return to previous string, no argument
-.define StringPrintDecimal 14 ;prints byte in decimal mode. uses substring in ram with return to print number. takes 4 parameter bytes, 3-byte adress of number to print, 1 byte for number length(valid values: 1-4). number can be 32bits long. (4294967295/$ffffffff max). if longer than 16bit, store low word first, then high word.
-.define StringEndNoCls		15 ;same as end string, but dont clear screen. (used for statusbox)
-.define StringSetPosition	16 ;changes tile draw position in vwf buffer. 1 argument, 0-128 valid
-.define StringSetSpeed		17	;set drawing speed. 1 argument: 0=slowest, 7f=fastest. msb set: draw instantly
-.define StringClsNoUpload	18	;clear screen, but don't upload vwf buffer so textbox doesnt flicker.
-.define StringGotoEvent 	19	;reset to debug mode
-.define StringCondGotoSub 20	;conditional goto substring. substring is only printed if all bits set in target bitmask are set in target byte. 6 arguments. arg0,1: substring number(word). arg2-4:target byte to check for condition. arg 5:bitmask to check for with target
-
-.define VwfPlotBufferLength	18*16*6	;tile number * tile length * line count
-.define VwfSpriteUpdFlagsLength	16	;10 sprites to update, upper 5 sprites at $0, lower 5 sprites at $8
-;*************************************************************************
-
-
-;*************************************************************************
-;nwarp daisakusen specific stuff:
-.define MaleHitpoints			8		;hp - health
-
-.define SpasmToRespawn		20
-.define DefaultBlockCounter 25		;number of frames to block after trigger
-
-;player objects:
-.define ObjEntryMaleDirection	ObjectList & $ffff + 28	;direction in which the object is currently facing
-							;0=down 1=up 2=left 3=right
-.define ObjEntryMaleHP		ObjectList & $ffff + 29	;amount of health this player has. 0=dead
-.define ObjEntryMaleInvinc	ObjectList & $ffff + 30	;if not zero, player is invincible
-.define ObjEntryMaleSpasmCount	ObjectList & $ffff + 30	;this is the revival counter. if a certain value is reached, player is revived with one hp.
-.define ObjEntryMaleBlockCounter	ObjectList & $ffff + 31	;this is the revival counter. if a certain value is reached, player is revived with one hp.
-.define OamTypeMainCharaCtrl		3		;main character top/controlling sprite
-.define MainCharaHotspotSize	32			;size of mainchara hotspot square in pixels
-.define NPCHotspotSizeX	14				;size of walking player hotspot square in pixels
-.define NPCHotspotSizeY	20				;size of walking player hotspot square in pixels
-.define NPCHitPointSizeX 12
-.define NPCHitPointSizeY 20
-
-
-;hdma gradient colors
-.define CreditsGradientColor	247	;cgram entry for color gradient
-.define TextBoxGradientColor	113	;cgram entry for color gradient
-.define BattleBoxGradientColor	113	;cgram entry for color gradient
-;*************************************************************************
-
-

+ 0 - 975
snes/loader/routines/dmafifo.asm

@@ -1,975 +0,0 @@
-/*
-todo:
-add a special case for uploading 2 vertical rows of the tilemap.
-doing this with 32 dma transfers of 4 bytes each is incredibly slow.
-better make a tight loop using vram acces 32byte increment that uploads the tilemap rows manually.
-
-
-guesstimate is that the dma fifo routine can transfer 130 bytes per scanline on average.
-normal transfers shouldnt be smaller than 128 bytes or so, otherwise the time needed to set up a dma transfer throws
-our timing off way too much.
-
-scanlines 200-261 can be used for uploads.
-maximum transfer length should be 2048 bytes.
-nmi eats about 8 scanlines.
-
-current guesstimate is 6784/$1a80 bytes per frame.
-
-this routine is used to dma transfer data to vram in bulk.
-other routines can queue writes into a fifo buffer and these then get transferred to vram during nmi or forced blank.
-
-;this only works for transfers from a-bus to vram to keep things simple
-;a transfer length of 0 marks the end of the buffer
-
-;WARNING!
-;this routine MUST have finished till nmi starts or it will produce glitched transfers! no longer true. was caused by some status stuff not being pushed to stack during irq entry.
-;overscan is enabled to lengthen the time available for dma'ing stuff from the dma fifo to vram
-;glitched transfer risk can be minimized by writing the dma count value last!!
-
-number of scanlines:	irq trigger:	nmi trigger normal:	irq trigger overscan:	
-ntsc: 261		200		225			240
-pal:  311		200		225			240
-
-
-
-
-maximum number of entries: 128
-
-
-dma queue format:
-offset:	length:	function:
-00	2	transfer length
-02	2	vram target
-04	2	a-bus source offset	
-06	1	a-bus source bank
-
-areas needed:
-DmaFifoBuffer	ds $1c0
-
-
-variables needed:
-DmaFifoPointer		dw		;relative pointer to current free entry in buffer
-DmaFifoSourcePointerLo	dw	
-DmaFifoSourcePointerBa	db
-
-fixed variable needed:
-.define DmaFifoEntryLength	7
-
-routine features:
-
-InitDmaFifo:
-	-clear dma fifo buffer
-	
-ProcessDmaFifo:
-	-setup initial dma regs
-	-process the list until a length of 0 is encountered
-	-reset DmaFifoPointer to 0
-
-transfer types:
-
-00=void, no transfer
-01=normal dma from a-bus adress to vram
-02=special manual transfer mode to upload vertical tilemap rows 
-03=special transfer,16x16 sprite
-04=special transfer, 32x32 sprite
-05=special transfer, 64x64 sprite
-06=special vwf transfer, converts 2bpp tiles to 4bpp. transfer length is number of tiles, not bytelength
-
-how to write entries into table, m/x=16bit, new:
-
-;transfer type 1, normal a-bus to vram dma:
-ldx.b DmaFifoPointer
-lda #1					;transfer type
-sta.l DmaFifoEntryType,x
-sta.l DmaFifoEntryCount,x		;length 4305
-sta.l DmaFifoEntryTarget,x		;vram target 2116
-sta.l DmaFifoEntrySrcLo,x		;source 4302
-sta.l DmaFifoEntrySrcHi,x		;source 4303
-sta.l DmaFifoEntrySrcBank,x		;source 4304
-
-	txa						;update fifo entry pointer
-	clc
-	adc.w #DmaFifoEntryLength
-	sta.b DmaFifoPointer
-
-;transfer type 2, upload vertical tilemap row from wram bank 7e to vram
-ldx.b DmaFifoPointer
-lda #2					;transfer type
-sta.l DmaFifoEntryType,x
-sta.l DmaFifoEntryTarget,x		;vram target 2116
-sta.l DmaFifoEntryCount,x		;number of lines to upload (one line has 32 entries), maximum 32 lines
-sta.l DmaFifoEntrySrcLo,x		;source 4302
-sta.l DmaFifoEntrySrcHi,x		;source 4303
-;sta.l DmaFifoEntrySrcBank,x		;source 4304
-
-
-	
-*/
-
-;waits for all dma transfers to be done and then one frame
-WaitDmaTransfersDone:
-	php
-	rep #$31
-WaitDmaTransfersDoneLoop:
-	lda.b DmaFifoPointer
-	bne WaitDmaTransfersDoneLoop
-
-
-	plp
-	rts
-
-;waits 2 frames to be sure all settings have been written to the video regs
-WaitFrame:
-;	rts
-	php
-	rep #$31
-
-WaitFrameIncDone:
-	lda.b FrameCounterLo
-	cmp.b FrameCounterLo
-	beq WaitFrameIncDone
-/*
-WaitFrameIncDone1:
-	lda.b FrameCounterLo
-	cmp.b FrameCounterLo
-	beq WaitFrameIncDone1
-*/
-
-	plp
-	rts
-	
-InitDmaFifo:
-	php
-	rep #$31
-	lda.w #0		;clear word: $0000
-	sta.l (DmaFifoPointer+$7e0000)			;reset fifo pointer
-	sta.l (DmaFifoPointerIrq+$7e0000)			;reset fifo pointer
-	ldy.w #DmaFifoEntryLength*256
-	ldx.w #DmaFifoBuffer&$ffff
-	jsr ClearWRAM		
-	
-	
-;	sta.l (DmaFifoOverhang+$7e0000)
-;	sta.l (DmaFifoTotalBytesTransferred+$7e0000)
-
-	plp
-	rts
-
-ProcessDmaFifoTypeLUT:
-	.dw ProcessDmaFifoTypeVoid
-	.dw ProcessDmaFifoTypeNormalDma
-	.dw ProcessDmaFifoTypeVTilemapRow
-	.dw ProcessDmaFifoType16x16Sprite
-	.dw ProcessDmaFifoType32x32Sprite
-	.dw ProcessDmaFifoType64x64Sprite
-	.dw ProcessDmaFifoTypeVwf2bppTo4bpp
-	.dw UploadBg1Tilemap
-	.dw UploadBg2Tilemap
-
-	.dw UploadBg3Tilemap
-	.dw NMIUploadPal
-	.dw NMIUploadOAM
-	.dw ProcessDmaFifoTypeVoid	
-	.dw ProcessDmaFifoTypeVoid
-	.dw ProcessDmaFifoTypeVoid
-	.dw ProcessDmaFifoTypeVoid
-	.dw ProcessDmaFifoTypeVoid	
-
-ProcessDmaFifoTypeVoid:
-;	sec
-	rts
-
-ProcessDmaFifoTypeVwf2bppTo4bpp:
-;setup some dma regs that always stay the same on all transfers:	
-	lda.w #$1801			;Set the DMA mode (word, normal increment)
-	sta.w $4300 
-	
-	lda.b [DmaFifoSourcePointerLo],y
-	and.w #$7f								;128 tiles max(vram vwf buffer size)
-	beq ProcessDmaFifoTypeVwf2bppTo4bppAbort	
-	
-	sta.b TempBufferIrq						;number of tiles to transfer, counter
-/*	
-	asl a									;multiply by 16(length of one 2bpp tile)
-	asl a
-	asl a
-	asl a
-	clc
-	adc.b DmaFifoTotalBytesTransferred
-	sta.b DmaFifoTotalBytesTransferred
-*/
-	lda.w #16								;transfer length, one tile
-	sta.w $4305
-	
-	
-	
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.b TempBufferIrq+2			;vram target
-	sta.w $2116
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.b TempBufferIrq+4			;dma source
-	sta.w $4302
-	iny
-	lda.b [DmaFifoSourcePointerLo],y	;dma source, high byte and bank
-	iny
-	iny
-;	iny
-	sta.w $4303
-
-ProcessDmaFifoTypeVwf2bppTo4bppLoop:
-	sep #$20
-	lda #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-
-	lda.b #$01
-	sta.w $420b
-
-	dec.b TempBufferIrq			;counter
-	beq ProcessDmaFifoTypeVwf2bppTo4bppAbort		;all tiles uploaded?
-
-	
-	rep #$31
-	
-	lda.b TempBufferIrq+2
-;	clc
-	adc.w #32/2					;add one 4bpp tile to vram target
-	sta.b TempBufferIrq+2
-	sta.w $2116
-	lda.b TempBufferIrq+4
-	clc
-	adc.w #16					;add one 2bpp tile to wram source
-	sta.b TempBufferIrq+4
-	sta.w $4302
-	lda.w #16				;transfer length, one line
-	sta.w $4305
-	bra ProcessDmaFifoTypeVwf2bppTo4bppLoop
-	
-ProcessDmaFifoTypeVwf2bppTo4bppAbort:
-	rts
-
-ProcessDmaFifoType16x16Sprite:
-	lda.w #$1801			;Set the DMA mode (word, normal increment)
-	sta.w $4300 
-	
-	lda.w #64				;transfer length, one line
-	sta.w $4305
-/*
-	lda.w #64*8
-	clc
-	adc.b DmaFifoTotalBytesTransferred
-	sta.b DmaFifoTotalBytesTransferred
-*/	
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.b TempBufferIrq			;vram target
-	sta.w $2116
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.b TempBufferIrq+2			;dma source
-	sta.w $4302
-	iny
-	lda.b [DmaFifoSourcePointerLo],y	;dma source, high byte and bank
-	iny
-	iny
-;	iny
-	sta.w $4303
-     
-
-	sep #$20
-	lda #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #64					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #64				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b
-	rts
-
-ProcessDmaFifoType32x32Sprite:
-	lda.w #$1801			;Set the DMA mode (word, normal increment)
-	sta.w $4300 
-
-	lda.w #128				;transfer length, one line
-	sta.w $4305
-/*
-	lda.w #128*8
-	clc
-	adc.b DmaFifoTotalBytesTransferred
-	sta.b DmaFifoTotalBytesTransferred
-*/	
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.b TempBufferIrq			;vram target
-	sta.w $2116
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.b TempBufferIrq+2			;dma source
-	sta.w $4302
-	iny
-	lda.b [DmaFifoSourcePointerLo],y	;dma source, high byte and bank
-	iny
-	iny
-;	iny
-	sta.w $4303
-     
-
-	sep #$20
-	lda #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #128					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #128				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #128					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #128				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #128					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #128				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b	
-	rts
-
-;takes 19 lines for 2048 bytes. a single 2048 byte transfer takes 12 lines, so this could be sped up a bit still
-ProcessDmaFifoType64x64Sprite:
-	lda.w #$1801			;Set the DMA mode (word, normal increment)
-	sta.w $4300 
-
-;	lda.b [DmaFifoSourcePointerLo],y
-;	beq ProcessDmaFifoTypeNormalDmaAbort
-	lda.w #256				;transfer length, one line
-	sta.w $4305
-/*
-	lda.w #256*8
-	clc
-	adc.b DmaFifoTotalBytesTransferred
-	sta.b DmaFifoTotalBytesTransferred
-*/	
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.b TempBufferIrq			;vram target
-	sta.w $2116
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.b TempBufferIrq+2			;dma source
-	sta.w $4302
-	iny
-	lda.b [DmaFifoSourcePointerLo],y	;dma source, high byte and bank
-	iny
-	iny
-;	iny
-	sta.w $4303
-     
-
-	sep #$20
-	lda #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #256					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #256				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #256					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #256				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #256					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #256				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #256					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #256				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #256					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #256				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b
-	
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #256					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #256				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31
-	lda.b TempBufferIrq
-;	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBufferIrq
-	sta.w $2116
-	lda.b TempBufferIrq+2
-	clc
-	adc.w #256					;add one tileline in source
-	sta.b TempBufferIrq+2
-	sta.w $4302
-	lda.w #256				;transfer length, one line
-	sta.w $4305
-	sep #$20
-	lda.b #$01
-	sta.w $420b					
-	rep #$31			;clear carry, dont abort processing fifo list
-	rts
-
-
-ProcessDmaFifoTypeNormalDma:
-	lda.w #$1801			;Set the DMA mode (word, normal increment)
-	sta.w $4300 
-
-	lda.b [DmaFifoSourcePointerLo],y
-	beq ProcessDmaFifoTypeNormalDmaAbort
-	sta.w $4305
-/*	
-	cmp.w #DmaFifoMinTransferSize				;check if transfer is lower than 64 and load 64 for counter if it is. otherwise, these transfers screw up our calculation
-	bcs ProcessDmaFifoTypeNormalDmaBigEnough
-
-	lda.w #DmaFifoMinTransferSize				;load minimum length
-ProcessDmaFifoTypeNormalDmaBigEnough:
-	clc
-	adc.b DmaFifoTotalBytesTransferred
-	sta.b DmaFifoTotalBytesTransferred
-*/	
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.w $2116
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.w $4302
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	iny
-	iny
-;	iny
-	sta.w $4303
-;	lda #$18  			;Set the destination register (VRAM gate)
-;	sta $4301      
-
-	sep #$20
-	lda #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-
-	lda.b #$01
-	sta.w $420b
-
-	rep #$31			;clear carry, dont abort processing fifo list
-	rts
-
-ProcessDmaFifoTypeNormalDmaAbort:	;abort and go to next entry if a transfer length of 0 is encountered
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	rts
-
-ProcessDmaFifoTypeVTilemapRow:
-	lda.w #$1801			;Set the DMA mode (word, normal increment)
-	sta.w $4300 
-
-	sep #$20
-	lda #%10000001
-	sta $2115			;set VRAM transfer mode to word-access, increment by 64
-
-	rep #$31
-;	lda.b [DmaFifoSourcePointerLo],y	;get number of lines to transfer
-;	and #31					;maximum number of lines:32
-;	tax
-
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	sta.w $2116				;store vram target
-
-	iny
-	iny
-	lda.b [DmaFifoSourcePointerLo],y
-	tax					;source offset in bank $7e
-	iny
-	iny
-	iny
-	lda.l $7e0000,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$40,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$80,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$c0,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$100,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$140,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$180,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$1c0,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$200,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$240,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$280,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$2c0,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$300,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$340,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$380,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$3c0,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$400,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$440,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$480,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$4c0,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$500,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$540,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$580,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$5c0,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$600,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$640,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$680,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$6c0,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$700,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$740,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$780,x	
-	sta $2118			;write data to vram
-	lda.l $7e0000+$7c0,x	
-	sta $2118			;write data to vram
-	rts
-	
-
-
-/*	
-pointer
-pointerirq
-
--if pointer=0, exit immediately
--get pointerirq and do transfer its pointing to, then increase pointerirq by one entry
--if pointerirq is equal or bigger than pointer, clear pointer and pointerirq
-
-*/
-ProcessDmaFifo:
-	php
-	sep #$20
-;setup pointer to fifo buffer
-	lda.b #$7e
-	sta.b DmaFifoSourcePointerBa
-	rep #$31
-	lda.w #DmaFifoBuffer&$ffff
-	sta.b DmaFifoSourcePointerLo
-;	ldy.b DmaFifoOverhang			;normally 0. if the list wasnt finished last frame, we finish it now
-
-	ldy.b DmaFifoPointer
-	beq ProcessDmaFifoExit
-
-	
-ProcessDmaFifoLoop:
-	ldy.b DmaFifoPointerIrq	
-	lda.b [DmaFifoSourcePointerLo],y	;get transfer type
-	phy													;save for later
-	
-	and.w #$000f								;16 different transfer types only
-
-	asl a
-	tax
-	iny													;prepare pointer for dma upload routine
-	php
-	jsr (ProcessDmaFifoTypeLUT,x)
-	plp
-	
-	ply
-
-	lda.w #0
-	sta.b [DmaFifoSourcePointerLo],y		;clear this transfer type to be on the safe side
-	iny
-	iny
-	sta.b [DmaFifoSourcePointerLo],y
-	iny
-	iny
-	sta.b [DmaFifoSourcePointerLo],y
-	iny
-	iny
-	sta.b [DmaFifoSourcePointerLo],y
-	iny
-	iny
-	tya
-	sta.b DmaFifoPointerIrq						;update process pointer
-	cmp.b DmaFifoPointer
-	bcc ProcessDmaFifoNotDone					;done when process pointer is bigger than queue pointer			
-	
-	stz.b DmaFifoPointerIrq						;clear both pointers
-	stz.b DmaFifoPointer
-	bra ProcessDmaFifoExit
-
-
-ProcessDmaFifoNotDone:
-;	cpy.w #DmaFifoEntryLength*128	;check if whole list was processed
-	
-
-
-;check if scanline 238 has been passed:
-	sep #$20
-
-	lda.b #$80
-	sta.w $4201							;reset latch
-	nop
-	nop
-	nop
-	nop
-	lda.w $2137							;latch current scanline
-	lda.w $213f							;reset $213d lo/hi byte counter
-	lda.w $213d							;get low byte
-	xba
-	lda.w $213d							;get high byte
-	xba	
-	rep #$31
-	and.w #$1ff
-	cmp.w #199
-	bcc ProcessDmaFifoExit	;exit if lower than scanline 200 (wrapped around)
-	cmp.w #239
-	bcc ProcessDmaFifoLoop	;exit if bigger than scanline 237 (nearly at end of irq timeframe)
-
-	
-ProcessDmaFifoExit:
-
-;	jsr InitDmaFifo
-;	sty.b DmaFifoPointer		;should always be zero
-	plp
-	rts
-
-
-
-/*
-UploadBg1TilemapFifo:
-	php
-	rep #$31
-	ldx.b DmaFifoPointer
-	lda #1					;transfer type normal dma
-	sta.l DmaFifoEntryType,x
-	lda.b VramBg1Tilemap
-	sta.l DmaFifoEntryTarget,x		;vram target 2116
-	lda.w #Bg1MapBuffer & $ffff
-	sta.l DmaFifoEntrySrcLo,x		;source 4302
-	lda.w #$800
-	sta.l DmaFifoEntryCount,x		;length 4305
-	sep #$20
-	lda.b #(Bg1MapBuffer >> 16)
-	sta.l DmaFifoEntrySrcBank,x		;source 4304
-	rep #$31
-	txa						;update fifo entry pointer
-	adc.w #DmaFifoEntryLength
-	sta.b DmaFifoPointer
-
-
-	plp
-	rts
-*/
-
-
-
-NMIUploadPal:
-;transfer palette buffer to cgram
-	sep #$20
-	stz.w $2121			;upload colour-palette buffer at $7e:0e00 to cg-ram every frame
-	ldx #PaletteBuffer&$ffff			;start at color 0 
-	stx.w $4302			;Store the data offset into DMA source offset
-	ldx #$0200
-	stx.w $4305   			;Store the size of the data block
-	lda.b #$7e
-	sta.w $4304			;Store the data bank holding the tile data
-	lda.b #$00			;Set the DMA mode (byte, normal increment)
-	sta.w $4300       
-	lda.b #$22    			;Set the destination register ( $2122: CG-RAM Write )
-	sta.w $4301      
-	lda.b #$01    			;Initiate the DMA transfer
-	sta.w $420B
-;	stz.b NMIPaletteUploadFlag
-	rts
-
-NMIUploadOAM:
-;transfer sprite buffer to oamram
-	sep #$20
-	stz.w $2102			;upload to oam adress 0
-	stz.w $2103
-	ldx.w #OamBuffer&$ffff			;start at color 0 
-	stx.w $4302			;Store the data offset into DMA source offset
-	ldx.w #$0220
-	stx.w $4305   			;Store the size of the data block
-	lda.b #$7e
-	sta.w $4304			;Store the data bank holding the tile data
-	lda.b #$00			;Set the DMA mode (byte, normal increment)
-	sta.w $4300       
-	lda.b #$04    			;Set the destination register ( $2122: CG-RAM Write )
-	sta.w $4301      
-	lda.b #$01    			;Initiate the DMA transfer
-	sta.w $420B
-;	stz.b NMIOamUploadFlag		;clear upload flag
-	rts
-	
-BgTilemapSizeLUT:
-	.dw $800
-	.dw $1000
-	.dw $1000
-	.dw $2000
-	
-;NMIUploadBg1:
-UploadBg1Tilemap:
-	rep #$31
-	lda.b BG1TilemapVram
-	and.w #%11					;get tilemap size
-	asl a
-	tax
-	lda.l (BgTilemapSizeLUT+BaseAdress),x
-	sta.w $4305   			;Store the size of the data block
-;transfer bg1 tilemap to vram if needed:
-	sep #$20
-	ldx.b VramBg1Tilemap
-	stx.w $2116			;vram adress $0000
-	ldx.w #Bg1MapBuffer & $ffff
-	stx.w $4302			;Store the data offset into DMA source offset
-	
-	lda.b #(Bg1MapBuffer >> 16)
-	sta.w $4304			;Store the data bank of the source data
-	lda.b #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-	lda.b #$01			;Set the DMA mode (word, normal increment)
-	sta.w $4300       
-	lda.b #$18    			;Set the destination register (VRAM gate)
-	sta.w $4301      
-	lda.b #$01    			;Initiate the DMA transfer
-	sta.w $420B
-;	stz.b NMIBg1UploadFlag
-	rts
-	
-;NMIUploadBg2:	
-UploadBg2Tilemap:
-;transfer bg2 tilemap to vram if needed:
-	rep #$31
-	lda.b BG2TilemapVram
-	and.w #%11					;get tilemap size
-	asl a
-	tax
-	lda.l (BgTilemapSizeLUT+BaseAdress),x
-	sta.w $4305   			;Store the size of the data block
-	sep #$20
-	ldx.b VramBg2Tilemap
-	stx.w $2116			;vram adress $0000
-	ldx.w #Bg2MapBuffer & $ffff
-	stx.w $4302			;Store the data offset into DMA source offset
-;	ldx.w #$800
-;	stx.w $4305   			;Store the size of the data block
-	lda.b #(Bg2MapBuffer >> 16)
-	sta.w $4304			;Store the data bank of the source data
-	lda.b #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-	lda.b #$01			;Set the DMA mode (word, normal increment)
-	sta.w $4300       
-	lda.b #$18    			;Set the destination register (VRAM gate)
-	sta.w $4301      
-	lda.b #$01    			;Initiate the DMA transfer
-	sta.w $420B
-;	stz.b NMIBg2UploadFlag
-	rts	
-
-
-UploadBg3Tilemap:
-;transfer bg3 tilemap to vram if needed:
-	rep #$31
-	lda.b BG3TilemapVram
-	and.w #%11					;get tilemap size
-	asl a
-	tax
-	lda.l (BgTilemapSizeLUT+BaseAdress),x
-	sta.w $4305   			;Store the size of the data block
-	sep #$20
-	ldx.b VramBg3Tilemap
-	stx.w $2116			;vram adress $0000
-	ldx.w #Bg3MapBuffer & $ffff
-	stx.w $4302			;Store the data offset into DMA source offset
-;	ldx.w #$800
-;	stx.w $4305   			;Store the size of the data block
-	lda.b #(Bg3MapBuffer >> 16)
-	sta.w $4304			;Store the data bank of the source data
-	lda.b #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-	lda.b #$01			;Set the DMA mode (word, normal increment)
-	sta.w $4300       
-	lda.b #$18    			;Set the destination register (VRAM gate)
-	sta.w $4301      
-	lda.b #$01    			;Initiate the DMA transfer
-	sta.w $420B
-;	stz.b NMIBg3UploadFlag
-	rts	
-
-
-
-
-
-
-
-	

+ 0 - 90
snes/loader/routines/eventroutines.asm

@@ -1,90 +0,0 @@
-EventPtTable:
-	.dw EventRoutine0
-	.dw EventRoutine1
-	.dw EventRoutine2
-	.dw EventRoutine3
-
-	
-;boot init, also debug menu check		
-EventRoutine0:
-	rep #$31
-	lda.w #200
-	sta.w GravityCutOffYPos
-
-	sep #$20
-	lda.b #0
-	sta.b ScreenBrightness
-	lda.b #$80
-	sta.l $2100
-
-	jsr ROMToWRAM				;upload
-	jsr InitOam
-	jsr ResetScrollOffsets
-	jsr InitDmaFifo
-	jsr ClearColObjList
-	jsr ClearZBuffer
-	
-	stz.b FocusScreenFlags
-	lda.b #0
-	sta.b CheckJoypadMode		;set joypad check to 8 players
-	lda.b #$80
-	sta.w IrqBrightnessIncDec
-	lda.b #20
-	sta.w MaxGravObjCount
-
-
-	lda.b #0				;load bgmode config #1
-	jsr SetBGMode
-	jsr DMATilesToVramBG3
-	jsr ClearBg3TilemapBuffer		;cls
-	ldx.w #0
-	jsr LoadTextString		;print "startup ok"
-	
-	stz.b LoadMenuDoInit
-	lda.b #$0f
-	sta.b ScreenBrightness
-	inc.b CurrentEvent
-	rts
-
-;debug menu play
-EventRoutine1:
-	jsr ObjectProcessor
-	ldx.w #0
-	jsr LoadMenuFile
-
-	ldx.w #1
-	jsr LoadTextString		;print virqs
-	ldx.w #4
-	jsr LoadTextString		;print extirqs
-	ldx.w #5
-	jsr LoadTextString		;print $00:3000
-	
-	rts
-	
-
-
-;debug audio menu init	
-EventRoutine2:
-	sep #$20
-	jsr ClearBg3TilemapBuffer		;cls
-	ldx.w #3
-	jsr LoadTextString		;print audio menu
-	stz.b LoadMenuDoInit
-	inc CurrentEvent
-
-;debug audio menu play	
-EventRoutine3:
-	jsr ObjectProcessor
-
-	ldx.w #1
-	jsr LoadMenuFile
-	ldx.w #13
-	jsr LoadTextString		;print timecode
-	ldx.w #14
-	jsr LoadTextString
-	ldx.w #30
-	jsr LoadTextString		;print channel volume output
-	ldx.w #31
-	jsr LoadTextString	
-	rts
-		

+ 0 - 662
snes/loader/routines/gfxvrammisc.asm

@@ -1,662 +0,0 @@
-
-;init variables:
-;a(8bit) is index into bgmode 2byte pointertable
-SetBGMode:
-	php
-	rep #$31				;accu 16bit
-	and.w #$000f				;16 valid entries
-	asl a 
-	tax
-	lda.l BgModeLut+BaseAdress,x
-;	lda.b UploadBackgroundPointer+1		;get source bank of tilemap
-	sta.b SetBGThreeBytePointerLo		;
-
-	sep #$20
-	lda.b #(:BgModeLut+BaseAdress>>16)
-	sta.b SetBGThreeBytePointerBank		;
-	ldy.w #$0000
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b SetIni
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b ScreenMode
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b MainScreen
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b SubScreen
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b CGWsel
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b CgadsubConfig
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b BGTilesVram12
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b BGTilesVram34
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b BG1TilemapVram
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b BG2TilemapVram
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b BG3TilemapVram
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b BG4TilemapVram
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b ObjSel
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	jsr IrqInit
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b W12SEL
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b W34SEL
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b WOBJSEL
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b W1L
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b W1R
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b W2L
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b W2R
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b WBGLOG
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b WOBJLOG
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b WMS
-	iny
-	lda.b [SetBGThreeBytePointerLo],y		;load byte from table
-	sta.b WSS
-
-
-	
-
-;init vram locations	
-	rep #$31
-	lda.b BGTilesVram12
-	pha
-	and.w #$00f0
-	xba
-	sta.b VramBg2Tiles
-	
-	pla
-	and.w #$000f
-	xba
-	clc
-	asl a
-	asl a
-	asl a
-	asl a
-	sta.b VramBg1Tiles
-
-	lda.b BGTilesVram34
-	pha
-	and.w #$00f0
-	xba
-	sta.b VramBg4Tiles
-	
-	pla
-	and.w #$000f
-	xba
-	clc
-	asl a
-	asl a
-	asl a
-	asl a
-	sta.b VramBg3Tiles
-
-	
-	lda.b BG1TilemapVram
-	and.w #$00fc
-	xba
-	sta.b VramBg1Tilemap
-
-	lda.b BG2TilemapVram
-	and.w #$00fc
-	xba
-	sta.b VramBg2Tilemap
-
-	lda.b BG3TilemapVram
-	and.w #$00fc
-	xba
-	sta.b VramBg3Tilemap
-
-	lda.b BG4TilemapVram
-	and.w #$00fc
-	xba
-	sta.b VramBg4Tilemap
-	
-	lda.b ObjSel
-	and.w #%111			;get spritetile base adress
-	asl a				;shift left by 5
-	asl a
-	asl a
-	asl a
-	asl a
-	xba				;shift left by 8
-	sta.b SpriteTileOffsetVram
-	
-	plp
-	rts
-
-
-
-
-
-;**********************************
-;Simple Background loader for bg1 and 2
-;in:	a,8bit: bit0,1:   bg number, 0-3
-;		bit2-4: palette to use
-;		bit5:   priority bit
-;in:	x,16bit: pointernumber of background
-;
-;every background consists of 1.tiles,2.tilemap,3.pal+header(relative pointers to all 3 files+eof)
-;
-;uses: TempBuffer0-8
-;**********************************
-
-UploadBackgroundFile:
-	php
-	sep #$20
-
-	sta.b TempBuffer+2
-
-	rep #$31
-;	and.w #$ff
-	txa
-	sta.b TempBuffer+4			;multiply background number by 3
-	asl a
-	adc.b TempBuffer+4
-	tax
-	lda.l UploadBackgroundFileLUT+BaseAdress,x		;get pointer low byte to background
-	sta.b TempBuffer+4
-	inx
-	lda.l UploadBackgroundFileLUT+BaseAdress,x		;get pointer high word to background
-	sta.b TempBuffer+5
-
-	sep #$20
-	
-	sei
-	jsr UploadTiles	
-	jsr UploadTilemap
-	cli
-
-	plp
-	rts
-	
-UploadTiles:
-	sep #$20
-	ldx.b DmaFifoPointer
-	lda #1					;transfer type
-	sta.l DmaFifoEntryType,x
-	
-	lda.b TempBuffer+6			;get source bank
-
-	sta.l DmaFifoEntrySrcBank,x		;source 4304
-	
-	rep #$31
-	ldy.w #$0000
-	lda.b [TempBuffer+4],y		;get relative pointer to tiles
-	sta.b TempBuffer+7
-	adc.b TempBuffer+4			;add file offset
-
-	sta.l DmaFifoEntrySrcLo,x		;source 4302
-	
-	sec
-	iny
-	iny
-	lda.b [TempBuffer+4],y		;get relative pointer to tilemap
-	sbc.b TempBuffer+7		;substract tile position to get tile length
-
-	sta.l DmaFifoEntryCount,x			;length 4305
-	
-	lda.b TempBuffer+2
-	and.w #%11
-	asl a
-	tay
-
-	lda.w VramBg1Tiles,y					;get vram destination
-
-	sta.l DmaFifoEntryTarget,x		;vram target 2116
-
-	txa						;update fifo entry pointer
-	clc
-	adc.w #DmaFifoEntryLength
-	sta.b DmaFifoPointer
-
-	rts
-
-BgMapBufferLUT:
-	.dw Bg1MapBuffer&$ffff
-	.dw Bg2MapBuffer&$ffff
-	.dw Bg3MapBuffer&$ffff
-	.dw Bg4MapBuffer&$ffff
-
-UploadTilemap:
-;copy tilemap to wram buffer:
-	php
-	sep #$20
-
-	phb
-	lda.b #$81
-	pha
-	plb
-
-	lda.b #Bg1MapBuffer >> 16		;store target adress(map buffer) in ram port.
-	and.b #$01				;only 1 or 0 valid for banks $7e or $7f
-	sta.w $2183
-
-	rep #$31
-	lda.b TempBuffer+2
-	and.w #%11
-	asl a
-	tax
-	lda.l (BgMapBufferLUT+BaseAdress),x
-	
-	sta.w $2181	
-	sep #$20
-	lda.b TempBuffer+2			;save layer bit
-;	pha
-	
-	and.b #$3c				;mask off everything but palette and priority bit
-	sta.b TempBuffer+3
-
-	rep #$31				;accu 16bit
-	lda.b TempBuffer+5		;get source bank of tilemap
-	sta.b ThreeBytePointerHi		;
-
-	ldy.w #$0002
-	lda.b [TempBuffer+4],y	;get relative pointer to tilemap
-	sta.b TempBuffer+7
-	adc.b TempBuffer+4
-	sta.b ThreeBytePointerLo
-	iny
-	iny
-	lda.b [TempBuffer+4],y	;get relative pointer to palette(in order to calculate tilemap length)
-	
-	sec
-	sbc.b TempBuffer+7
-	sta.b TempBuffer			;store total length for dma transfer
-	and.w #$fffe				;mask off bit0 so the next loop never hangs
-	
-	tax					;get length, store in x
-	
-	ldy.w #$0000
-	sep #$20
-	
-DMAUploadTilemapLoop:
-	lda.b [ThreeBytePointerLo],y		;load word from ThreeBytePointer
-	sta.w $2180				;store in bg1 map buffer, low byte
-	iny
-	lda.b [ThreeBytePointerLo],y		;load word from ThreeBytePointer
-	and.b #$c3
-	ora.b TempBuffer+3			;or with priority and palette
-	sta.w $2180				;store in bg1 map buffer, low byte
-	iny
-	dex					;word-dec length counter
-	dex
-	bne DMAUploadTilemapLoop		;done if length counter = 0
-
-;	pla
-;	sta.b UploadBackgroundLayer
-;	jsr DMAUploadBgTilemap
-
-	rep #$31
-	lda.b TempBuffer+2
-	and.w #%11
-	tax
-	inc.b NMIBg1UploadFlag,x		;set corresponding bg tilemap update flag
-	sep #$20
-
-DMAUploadPaletteBG1:
-	lda.b #PaletteBuffer >> 16		;store target adress(palette buffer) in ram port.
-	and.b #$01				;only 1 or 0 valid for banks $7e or $7f
-	
-	lda.b TempBuffer+2
-	bit.b #%10						;do an extra shift if this is bg0 or 1(bg0,1:always 16 color palettes /bg2,3: always 4 colors)
-	beq DMAUploadPaletteBG1jaja
-	and.b #%00011100			;mask off everything but palette number
-	asl a					;multiply by 8(2bytes per color x 4 colors per palette)	
-	bra DMAUploadPaletteBGSelectDone
-
-DMAUploadPaletteBG1jaja:
-	and.b #%00011100			;mask off everything but palette number
-	asl a
-	asl a
-	asl a					;multiply by 32(2bytes per color x 16 colors per palette)	
-	
-DMAUploadPaletteBGSelectDone:
-	rep #$31
-	and.w #$00ff
-	tax
-	lda.b TempBuffer+5		;get source bank of palette
-	sta.b ThreeBytePointerHi		;
-
-	ldy.w #$0004
-	lda.b [TempBuffer+4],y	;get relative pointer to palette
-	sta.b TempBuffer+7
-	adc.b TempBuffer+4
-	sta.b ThreeBytePointerLo
-
-	iny
-	iny
-	lda.b [TempBuffer+4],y	;get relative pointer to EOF(in order to calculate tilemap length)
-	
-	sec
-	sbc.b TempBuffer+7
-
-	sta.b TempBuffer
-
-	ldy.w #$0000				;clear target/source counter						
-
-DMAUploadPaletteBG1Loop:
-	sep #$20
-	lda.b [ThreeBytePointerLo],y				;load word from ThreeBytePointer
-
-	sta.l PaletteBuffer,x				;store in bg1 map buffer
-	rep #$31
-
-	iny
-	inx
-	dec.b TempBuffer					;word-dec length counter
-	bne DMAUploadPaletteBG1Loop		;done if length counter = 0
-	
-	sep #$20
-	inc.b NMIPaletteUploadFlag
-	plb
-	plp
-	rts
-
-	
-ClearPalette:
-   PHX
-   PHP
-   REP #$30		; mem/A = 8 bit, X/Y = 16 bit
-   SEP #$20
-   STZ $2121
-   LDX #$0100
-ClearPaletteLoop:
-   STZ $2122
-   DEX
-   BNE ClearPaletteLoop
-
-   PLP
-   PLX
-   RTS
-   
-ClearPaletteBuffer:
-	php
-	rep #$31
-	sep #$20
-	lda.b #0		;clear word: $0000
-	ldy.w #$200
-	ldx.w #PaletteBuffer&$ffff
-	jsr ClearWRAM
-	
-	
-	plp
-	rts
-/*
-
-	ldx.w #$0200
-ClearPaletteBufferLoop:
-	dex
-	stz.w PaletteBuffer&$ffff,x
-	cpx.w #$0000
-	bne ClearPaletteBufferLoop
-	rts
-*/
-ClearBg1TilemapBuffer:
-	php
-	rep #$31
-	sep #$20
-	lda.b #0		;clear word: $0000
-	ldy.w #$800
-	ldx.w #Bg1MapBuffer&$ffff
-	jsr ClearWRAM
-	plp	
-	rts
-	
-
-
-/*
-	php
-	rep #$30
-	lda.w #$0000
-	ldx.w #$0800
-ClearBg1TilemapBufferLoop:
-	sta.l Bg1MapBuffer,x
-	dex
-	dex
-	bne ClearBg1TilemapBufferLoop
-	plp
-	rts
-*/	
-ClearBg2TilemapBuffer:
-	php
-	rep #$31
-	sep #$20
-	lda.b #0		;clear word: $0000
-	ldy.w #$800
-	ldx.w #Bg2MapBuffer&$ffff
-	jsr ClearWRAM
-	plp	
-	rts
-
-/*
-	php
-	rep #$30
-	lda.w #$0000
-	ldx.w #$0800
-ClearBg2TilemapBufferLoop:
-	sta.l Bg2MapBuffer,x
-	dex
-	dex	
-	bne ClearBg2TilemapBufferLoop
-	plp
-	rts
-*/
-ClearBg3TilemapBuffer:
-	php
-	rep #$31
-	sep #$20
-	lda.b #2		;clear word: $2480
-	ldy.w #$800
-	ldx.w #Bg3MapBuffer&$ffff
-	jsr ClearWRAM
-	plp	
-	rts
-
-/*
-	php
-	rep #$30
-	lda.w #$2480				;bg3 tilemap clearing tile, priority set
-	ldx.w #$0800
-ClearBg3TilemapBufferLoop:
-	sta.l Bg3Buffer-2,x
-	dex
-	dex	
-	bne ClearBg3TilemapBufferLoop
-	plp
-	rts
-*/
-
-;uploades any otherwise unfitting piece of gfx-tiles to vram
-;in:a,8bit: tileset number
-;		y,16bit: vram target
-; transfer length is determined by tileset
-;uses TempBuffer, TempBuffer+1
-GeneralVramUploader:
-;	lda.w #(TabTestTile8x8TilesEnd-TabTestTile8x8Tiles)
-	php
-	sep #$20
-	sta.b TempBuffer
-	phb
-	lda.b #$7e
-	pha
-	plb
-	rep #$31
-	sei
-	tya
-	ldy.b DmaFifoPointer
-	sta.w DmaFifoEntryTarget&$ffff,y		;vram target 2116
-
-	lda.b TempBuffer										;multiply by 5
-	and.w #$ff
-	sta.b TempBuffer
-	asl a
-	asl a
-	clc
-	adc.b TempBuffer
-	tax
-	lda.l (GeneralTilesetsLUT+BaseAdress),x		;get source adress
-	sta.b TempBuffer
-	
-	sta.w DmaFifoEntrySrcLo&$ffff,y		;source 4302
-	inx
-	lda.l (GeneralTilesetsLUT+BaseAdress),x		;get source adress
-	
-	sta.w DmaFifoEntrySrcHi&$ffff,y		;source 4303
-	
-	inx
-	inx
-	lda.l (GeneralTilesetsLUT+BaseAdress),x		;get source length
-	sta.w DmaFifoEntryCount&$ffff,y
-
-
-	sep #$20
-	lda #1					;transfer type normal dma
-	sta.w DmaFifoEntryType&$ffff,y
-	
-	rep #$31
-	tya						;update fifo entry pointer
-	clc
-	adc.w #DmaFifoEntryLength
-	sta.b DmaFifoPointer
-	cli
-	
-	
-	plb
-	plp
-	rts	
-
-
-IncBrightness:
-	php
-	rep #$30
-	sep #$20
-	lda FrameCounterLo	;load current frame
-	and BrightnessSpeed	;and check selected bits(the more, the slower)
-	bne DontIncBrightness	;only change brightness every second frame
-	lda ScreenBrightness
-	and #$0f			;and only brightness regs
-	cmp #$0f			;skip increase
-	beq DoneIncBrightness	;if maximum brightness is reached
-	inc ScreenBrightness	;change brightness
-	plp
-	rts	
-DontIncBrightness:
-	plp
-	rts				;do nothing
-DoneIncBrightness
-	plp
-	rts				;and return
-
-DecBrightness:
-	lda FrameCounterLo	;load current frame
-	and BrightnessSpeed	;and check selected bits(the more, the slower)
-	bne DontDecBrightness	;only change brightness every second frame
-	lda ScreenBrightness
-	and #$0f			;and only brightness regs
-	beq DoneDecBrightness
-	dec ScreenBrightness	;change brightness
-	rts	
-DontDecBrightness:
-	rts				;do nothing
-DoneDecBrightness:
-	inc CurrentEvent		;go to next event if done with brightness change
-	rts				;and return
-DisableScreen:
-	php
-	sep #$20
-	lda.b #%10000000			;force blanking
-	sta $2100			;
-
-
-	plp
-	rts
-	
-EnableScreen:
-	php
-	sep #$20
-
-
-	LDA $4210		;reg $4210  - NMI status, reading resets
-	cli
-	lda ScreenBrightness	;setup screen brightness
-	and #$7f			;screen always on and enabled
-	sta $2100
-	plp
-	rts
-
-ResetScrollOffsets:
-	php
-	rep #$31
-	lda.w #$3ff
-	sta.w BG1VOfLo		;
-	sta.w BG2VOfLo		;
-
-	stz.w BG1HOfLo
-	stz.w BG2HOfLo		;reset all bg1/bg2 offsets
-	stz.w BG2VOfLo		;
-
-	stz.w ScreenPixelPositionX
-	stz.w ScreenPixelPositionY
-	plp
-	rts
-
-;**********************************
-;fade in/fade out
-;in:	a/8bit: number of sample when fadeout should start
-;event is incremented automatically once fadeout is complete
-;**********************************
-FadeInFadeOut:
-	cpx.w FrameCounterLo
-	bpl EventRoutineContinue
-
-	lda #$03
-	sta BrightnessSpeed
-	jsr DecBrightness
-	rts	
-
-EventRoutineContinue:
-	lda #$03
-	sta BrightnessSpeed
-	jsr IncBrightness
-	rts
-	
-
-
-

+ 0 - 362
snes/loader/routines/irq.asm

@@ -1,362 +0,0 @@
-/*
-IRQ Routine
-Features: jumps to different Irq routines depending on variable
-
-Variables needed:
-IrqRoutineNumber	db			;
-IrqVCounter		dw
-
-if IrqRoutineNumber=0, irq is disabled
-
-irqloader:
-actual irq routine
-
-irqinit:
-this must be called whenever a different irq is asserted
-
-*/
-
-;in: a,8bit=number of irq routine to set,0 is disable
-IrqInit:
-	php
-	sep #$20
-	sta.b IrqRoutineNumber
-	sta.b IrqRoutineNumberBuffer
-;get initial latch value
-	rep #$31
-	and.w #%00000111		;maximum number of routines: 8
-	asl a				;word pointer
-	sta.b TempBufferIrq
-	asl a				;h/v latch values, multiply by 6
-	clc
-	adc.b TempBufferIrq
-	
-	tax
-	
-	lda.l (IrqRoutineLUT+BaseAdress+2),x
-	sta.b IrqVCounter
-	lda.l (IrqRoutineLUT+BaseAdress+4),x
-	sta.b IrqHCounter
-	
-;	sta.w $2109
-;	stz.w $2107
-	
-	plp
-	rts
-
-IrqLoader:
-;	php				;backup status, then switch to 16bit a/x in order to preserve everything and not just 8bit of the accu
-	rep #$39		
-	pha
-	phx
-	phy
-	phd
-	phb
-	
-	
-	lda.w #$0000
-	tcd
-;	jml (IrqLoaderHirom + BaseAdress)
-IrqLoaderHirom:	
-	sep #$20
-	lda.b #$81
-	pha
-	plb
-	
-	rep #$31
-	lda.b IrqRoutineNumber
-	and.w #%00000111		;maximum number of routines: 8
-	asl a				;word pointer
-	sta.b TempBufferIrq
-	asl a				;h/v latch values, multiply by 6
-	clc
-	adc.b TempBufferIrq
-	tax
-;	php
-	jsr (IrqRoutineLUT,x)
- ;	plp
-
-
-
-	
-	rep #$39
-	lda.w $4211			;clear irq flag
-	plb
-	pld
-	ply
-	plx
-	pla
-;	plp
-	rti
-
-
-
-IrqRoutineLUT:
-	.dw IrqRoutine0				;pointer to routine
-	.dw 200						;v-counter for this irq
-	.dw 130						;h-counter for this irq
-	.dw IrqRoutine1
-	.dw 200
-	.dw 130
-	.dw IrqRoutine2
-	.dw 143						;v-counter for this irq
-	.dw 130						;h-counter for this irq
-	.dw IrqRoutine3
-	.dw 0						;v-counter for this irq
-	.dw 0						;h-counter for this irq
-	.dw IrqRoutine4
-	.dw 0						;v-counter for this irq
-	.dw 0						;h-counter for this irq
-	.dw IrqRoutine5
-	.dw 0						;v-counter for this irq
-	.dw 0						;h-counter for this irq
-	.dw IrqRoutine6
-	.dw 0						;v-counter for this irq
-	.dw 0						;h-counter for this irq
-	.dw IrqRoutine7
-	.dw 0						;v-counter for this irq
-	.dw 0						;h-counter for this irq
-
-
-IrqRoutine0:
-	sep #$20
-	lda.b #$2f			;set bg color to red
-	sta.w $2132	
-	rep #$31
-	inc.w ExtIrqCounter
-	rts
-IrqRoutine1:
-
-	sep #$20			;enable forced blank
-
-	lda.b #$8f			;set bg color to blue
-	sta.w $2132
-	rep #$31	
-	inc.w VIrqCounter
-
-	rts
-	
-	
-IrqRoutine2:
-	sep #$20
-/*
-	lda.b MainScreen						;disable sprites below textbox top
-	and.b #%01111
-	sta.w $212c
-*/	
-	lda.b #$40
-	dec.b IrqRoutineNumber			;set up dma fifo irq below
-
-	stz.w $210f									;reset bg2 scrolling
-	stz.w $210f
-	stz.w $2110
-	stz.w $2110
-	
-
-
-	lda.b BGTilesVram12					;set bg2 new tile adress
-	and.b #$0f
-	ora.b #$70
-	sta.w $210B
-
-	lda.b BG3TilemapVram				;use bg3 map buffer for bg2 textbox after irq split
-	and.b #%11111100						;mask off bg size bits
-	sta.w $2108		
-	
-	rep #$31
-	lda.w #200									;set up irq counter for dma fifo
-	sta.w $4209
-	lda.w #130
-	sta.w $4207
-	
-
-
-	
-
-	
-	rts
-	
-IrqRoutine3:	
-IrqRoutine4:
-IrqRoutine5:
-IrqRoutine6:
-IrqRoutine7:
-	rts
-
-;checks if tilemap upload flags are set and issues one transfer per bg neccessary
-;in: 8bit accu	
-IrqCheckTilemapFlags:
-	lda.b NMIPaletteUploadFlag
-	beq IrqDontUploadPal
-
-	stz.w $2121			;upload colour-palette buffer at $7e:0e00 to cg-ram every frame
-	ldx #PaletteBuffer&$ffff			;start at color 0 
-	stx.w $4302			;Store the data offset into DMA source offset
-	ldx #$0200
-	stx.w $4305   			;Store the size of the data block
-	lda.b #$7e
-	sta.w $4304			;Store the data bank holding the tile data
-	lda.b #$00			;Set the DMA mode (byte, normal increment)
-	sta.w $4300       
-	lda.b #$22    			;Set the destination register ( $2122: CG-RAM Write )
-	sta.w $4301      
-	lda.b #$01    			;Initiate the DMA transfer
-	sta.w $420B
-	stz.b NMIPaletteUploadFlag
-		
-	
-IrqDontUploadPal:		
-	lda.b NMIOamUploadFlag
-	beq IrqDontUploadOAM
-
-	
-	stz.w $2102			;upload to oam adress 0
-	stz.w $2103
-	ldx.w #OamBuffer&$ffff			;start at color 0 
-	stx.w $4302			;Store the data offset into DMA source offset
-	ldx.w #$0220
-	stx.w $4305   			;Store the size of the data block
-	lda.b #$7e
-	sta.w $4304			;Store the data bank holding the tile data
-	lda.b #$00			;Set the DMA mode (byte, normal increment)
-	sta.w $4300       
-	lda.b #$04    			;Set the destination register ( $2122: CG-RAM Write )
-	sta.w $4301      
-	lda.b #$01    			;Initiate the DMA transfer
-	sta.w $420B
-	
-	stz.b NMIOamUploadFlag
-	
-	
-IrqDontUploadOAM:
-	lda.b NMIBg1UploadFlag
-	beq IrqDontUploadBg1
-
-	rep #$31
-	lda.b BG1TilemapVram
-	and.w #%11					;get tilemap size
-	asl a
-	tax
-	lda.l (BgTilemapSizeLUT+BaseAdress),x
-	sta.w $4305   			;Store the size of the data block
-;transfer bg1 tilemap to vram if needed:
-	sep #$20
-	ldx.b VramBg1Tilemap
-	stx.w $2116			;vram adress $0000
-	ldx.w #Bg1MapBuffer & $ffff
-	stx.w $4302			;Store the data offset into DMA source offset
-	
-	lda.b #(Bg1MapBuffer >> 16)
-	sta.w $4304			;Store the data bank of the source data
-	lda.b #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-	lda.b #$01			;Set the DMA mode (word, normal increment)
-	sta.w $4300       
-	lda.b #$18    			;Set the destination register (VRAM gate)
-	sta.w $4301      
-	lda.b #$01    			;Initiate the DMA transfer
-	sta.w $420B
-	stz.b NMIBg1UploadFlag
-
-
-IrqDontUploadBg1:	
-	lda.b NMIBg2UploadFlag
-	beq IrqDontUploadBg2
-
-	rep #$31
-	lda.b BG2TilemapVram
-	and.w #%11					;get tilemap size
-	asl a
-	tax
-	lda.l (BgTilemapSizeLUT+BaseAdress),x
-	sta.w $4305   			;Store the size of the data block
-	sep #$20
-	ldx.b VramBg2Tilemap
-	stx.w $2116			;vram adress $0000
-	ldx.w #Bg2MapBuffer & $ffff
-	stx.w $4302			;Store the data offset into DMA source offset
-;	ldx.w #$800
-;	stx.w $4305   			;Store the size of the data block
-	lda.b #(Bg2MapBuffer >> 16)
-	sta.w $4304			;Store the data bank of the source data
-	lda.b #$80
-	sta.w $2115			;set VRAM transfer mode to word-access, increment by 1
-	lda.b #$01			;Set the DMA mode (word, normal increment)
-	sta.w $4300       
-	lda.b #$18    			;Set the destination register (VRAM gate)
-	sta.w $4301      
-	lda.b #$01    			;Initiate the DMA transfer
-	sta.w $420B
-	stz.b NMIBg2UploadFlag
-
-IrqDontUploadBg2:
-	lda.b NMIBg3UploadFlag
-	beq IrqDontUploadBg3
-
-
-	ldx.b DmaFifoPointer
-	lda.b #9					;transfer type bg3 tilemap
-	sta.l DmaFifoEntryType,x
-
-	rep #$31
-	txa						;update fifo entry pointer
-	clc
-	adc.w #DmaFifoEntryLength
-	sta.b DmaFifoPointer
-	sep #$20
-	stz.b NMIBg3UploadFlag
-
-IrqDontUploadBg3:
-	rts	
-
-
-IrqBrightness:
-	sep #$20
-	lda.w IrqBrightnessIncDec		;if "done"-flag is set, do nothing
-	bmi IrqBrightnessExit
-
-	lsr a					;increase or decrease?
-	bcc IrqBrightnessDec
-
-	lda.b ScreenBrightness			;done with increasing?
-	cmp.b #$f
-	beq IrqBrightnessDone
-
-	lda.b ScreenBrightness
-	inc a					;decrease
-	sta.b ScreenBrightness
-	
-IrqBrightnessExit:
-	rts
-	
-
-IrqBrightnessDec:
-	lda.b ScreenBrightness			;done with decreasing?
-	beq IrqBrightnessDone
-	
-	lda.b ScreenBrightness
-	dec a					;decrease
-	sta.b ScreenBrightness
-
-	rts
-
-
-IrqBrightnessDone:
-	lda.w IrqBrightnessIncDec
-	ora.b #$80				;set "done"-flag
-	sta.w IrqBrightnessIncDec
-	rts
-	
-	
-WaitBrightnessDone:
-	php
-	sep #$20
-	
-WaitBrightnessLoop:	
-	lda.w IrqBrightnessIncDec		;wait for irq to finish brightness inc/dec
-	bpl WaitBrightnessLoop
-	
-	
-	plp
-	rts
-		

+ 0 - 126
snes/loader/routines/joypadread.asm

@@ -1,126 +0,0 @@
-
-CheckJoypadModeLUT:
-	.dw	CheckJoypadSinglePlayer
-	.dw CheckJoypad8Player
-	.dw CheckJoypadVoid
-	.dw CheckJoypadVoid
-	
-CheckJoypadVoid:
-	rts
-	
-
-;slow joypad checker, gets data for all 8 joypads with iobit=0.
-;writes collected data to 8 individual joypad buffers
-CheckJoypad8Player:  	
-	lda $4212
-	bit #$01
-	bne CheckJoypad8Player
-	
-	rep #$31
-	lda.w $4218
-	sta.w JoyPortBuffer&$ffff	;port1 pad 1
-	lda.w $421c
-	sta.w JoyPortBuffer&$ffff+2	;port1 pad 2	
-	lda.w $421a
-	sta.w JoyPortBuffer&$ffff+8	;port2 pad 1
-	lda.w $421e
-	sta.w JoyPortBuffer&$ffff+10	;port2 pad 2
-
-;assume we don't need to latch again:
-	sep #$20	
-  
-	lda.b #%11000000	;enable iobit on joyport1&2
-	sta.w $4201
-
-	lda.b #1
-  	sta.w $4016		;enable latching
-
-  	stz.w $4016		;latching end
-
-
-	rep #$31  
-
-  	ldx #16			;get 32 bits from every port
-CheckJoyPortsLoop3:
-	lda.w $4016
-      	lsr a			;put bit0 into carry
-      	rol.w JoyPortBuffer&$ffff+4		;port 1 pad 3
-      	lsr a			;put bit1 into carry
-      	rol.w JoyPortBuffer&$ffff+6		;port 1 pad 4
-	
-	asl a			;get upper byte
-	asl a
-	xba
-
-      	lsr a			;put bit0 into carry
-      	rol.w JoyPortBuffer&$ffff+12		;port 2 pad 3
-      	lsr a			;put bit1 into carry
-      	rol.w JoyPortBuffer&$ffff+14		;port 2 pad 4
-      	dex
-  	bne CheckJoyPortsLoop3	
-
-	sep #$20
-	lda.b #1
-  	sta.w $4016			;enable latching
-  	nop					;short delay is needed, otherwise mp5 sometimes doesn't respond in time.
-  	nop
-	lda.w $4016			;discard first read
-	lda.w $4016
-	and.b #%00000010	;get data1,2 bits only
-;	cmp.b #%10			;mp5 on port1?
-	bne Port1MP5Connected
-	
-	stz.w JoyPortBuffer&$ffff+4		;clear this joypads data if no mp5 connected
-	stz.w JoyPortBuffer&$ffff+5		;clear this joypads data if no mp5 connected
-	
-Port1MP5Connected:
-	lda.w $4017			;discard first read
-	lda.w $4017
-	and.b #%00000010	;get data1,2 bits only
-;	cmp.b #%10			;mp5 on port2?
-	bne Port2MP5Connected
-	
-	stz.w JoyPortBuffer&$ffff+$c		;clear this joypads data if no mp5 connected
-	stz.w JoyPortBuffer&$ffff+$d		;clear this joypads data if no mp5 connected
-	
-Port2MP5Connected:	
-  	stz.w $4016		;latching end
-
-	rep #$31
-	ldx.w #0
-CheckJoyPortsTriggerLoop:
-	lda.w JoyPortBufferOld&$ffff,x		;get last button state
-	eor.w #$ffff				;xor
-	sta.w JoyPortBufferTrigger&$ffff,x
-	lda.w JoyPortBuffer&$ffff,x
-	sta.w JoyPortBufferOld&$ffff,x
-	and.w JoyPortBufferTrigger&$ffff,x	;and and only get buttons that werent pressed last frame
-	sta.w JoyPortBufferTrigger&$ffff,x	;store in old joypad trigger buffer
-	inx
-	inx
-	cpx.w #8*2				;process 8 entries
-	bne CheckJoyPortsTriggerLoop
-
-
-	sep #$20
-	stz.w $4201		;clear iobit again.
-	rts
-
-
-;fast joy1 checker. check this late in nmi so we don't have to wait for auto joypad read to finish:
-CheckJoypadSinglePlayer:
-	lda $4212
-	bit #$01
-	bne CheckJoypadSinglePlayer
-
-	rep #$30
-	lda.w JoyPortBufferOld&$ffff	;get last button state
-	eor.w #$ffff			;xor
-	sta.w JoyPortBufferTrigger&$ffff
-	lda $4218
-	sta.w JoyPortBuffer&$ffff
-	sta.w JoyPortBufferOld&$ffff
-	and.w JoyPortBufferTrigger&$ffff	;and and only get buttons that werent pressed last frame
-	sta.w JoyPortBufferTrigger&$ffff	;store in joypad buffer
-	sep #$20
-	rts

+ 0 - 1128
snes/loader/routines/levelfiles.asm

@@ -1,1128 +0,0 @@
-
-.Section "LevelLUT" superfree
-LevelLUT:
-	.dw Map1 & $ffff
-	.db (:Map1+BaseAdress>>16)
-	.dw Map2 & $ffff
-	.db (:Map2+BaseAdress>>16)
-	.dw Map3 & $ffff
-	.db (:Map3+BaseAdress>>16)
-	.dw Map4 & $ffff
-	.db (:Map4+BaseAdress>>16)
-	.dw Map5 & $ffff
-	.db (:Map5+BaseAdress>>16)
-	.dw Map6 & $ffff
-	.db (:Map6+BaseAdress>>16)
-	.dw Map7 & $ffff
-	.db (:Map7+BaseAdress>>16)
-	.dw Map8 & $ffff
-	.db (:Map8+BaseAdress>>16)
-	.dw Map9 & $ffff
-	.db (:Map9+BaseAdress>>16)
-.ends
-
-.Section "level file 1" superfree
-Map1:
-	.db 28		;size in tiles, x
-	.db 26		;size in tiles, y
-	.db 0		;background color,r
-	.db 0		;background color,g
-	.db 0		;background color,b
-	.dw Map1Pal-Map1	;relative pointer(16bit) to palette
-	.dw Map1Col-Map1	;relative pointer(16bit) to collision map
-	.dw Map1Tile-Map1	;relative pointer(16bit) to image
-	.dw Map1EOF	;direct pointer(24bit) to EOF
-	.db (:Map1EOF)-(:Map1)+$c0
-	.dw Map1Exits-Map1
-;from here, total 19 additional bytes:
-	.dw Map1Objs-Map1
-Map1Exits:
-;exit 0:	
-
-;exit list terminator:	
-	.dw $0
-
-Map1Objs:
-/*
-;cpu usage
-	.db 1		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 00		;y-position/8
-*/
-;male 
-	.db 4		;object number
-	.db $80		;obj present flag
-	.db 7+2		;x-position/8
-	.db 6		;y-position/8
-;male 
-	.db 5		;object number
-	.db $80		;obj present flag
-	.db 10+2		;x-position/8
-	.db 8		;y-position/8
-;male 
-	.db 6		;object number
-	.db $80		;obj present flag
-	.db 11+2		;x-position/8
-	.db 11		;y-position/8
-;male 
-	.db 7		;object number
-	.db $80		;obj present flag
-	.db 25+2		;x-position/8
-	.db 12		;y-position/8
-;male 
-	.db 8		;object number
-	.db $80		;obj present flag
-	.db 22+2		;x-position/8
-	.db 14		;y-position/8		
-;male 
-	.db 9		;object number
-	.db $80		;obj present flag
-	.db 17+2		;x-position/8
-	.db 6		;y-position/8	
-;male 
-	.db 10		;object number
-	.db $80		;obj present flag
-	.db 12+2		;x-position/8
-	.db 16		;y-position/8	
-;male 
-	.db 11		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 18		;y-position/8	
-	
-											
-;obj list terminator:
-	.dw 0
-
-Map1Pal:
-	.incbin "data/levels/selectmap.clr" READ 124*2			;leave last 4 colors for onscreen text
-Map1Col:
-	.incbin "data/levels/selectmapcoli.bmp" SKIP $3e
-Map1Tile:
-	.incbin "data/levels/selectmap.pic" ;READ $7eb2		;$8000+32000+496
-
-
-	
-Map1EOF:
-.ends
-
-
-.Section "level file 2" superfree
-Map2:
-	.db 28		;size in tiles, x
-	.db 26		;size in tiles, y
-	.db 0		;background color,r
-	.db 0		;background color,g
-	.db 0		;background color,b
-	.dw Map2Pal-Map2	;relative pointer(16bit) to palette
-	.dw Map2Col-Map2	;relative pointer(16bit) to collision map
-	.dw Map2Tile-Map2	;relative pointer(16bit) to image
-	.dw Map2EOF	;direct pointer(24bit) to EOF
-	.db (:Map2EOF)-(:Map2)+$c0
-	.dw Map2Exits-Map2
-;from here, total 19 additional bytes:
-	.dw Map2Objs-Map2
-Map2Exits:
-;exit 0:	
-
-;exit list terminator:	
-	.dw $0
-
-Map2Objs:
-/*
-;cpu usage
-	.db 1		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 00		;y-position/8
-*/
-;male 
-	.db 4		;object number
-	.db $80		;obj present flag
-	.db 10+2		;x-position/8
-	.db 18		;y-position/8
-;male 
-	.db 5		;object number
-	.db $80		;obj present flag
-	.db 7+2		;x-position/8
-	.db 20		;y-position/8
-;male 
-	.db 6		;object number
-	.db $80		;obj present flag
-	.db 2+2		;x-position/8
-	.db 17		;y-position/8
-;male 
-	.db 7		;object number
-	.db $80		;obj present flag
-	.db 2+2		;x-position/8
-	.db 13		;y-position/8
-;male 
-	.db 8		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 9		;y-position/8		
-;male 
-	.db 9		;object number
-	.db $80		;obj present flag
-	.db 5+2		;x-position/8
-	.db 6		;y-position/8	
-;male 
-	.db 10		;object number
-	.db $80		;obj present flag
-	.db 8+2		;x-position/8
-	.db 4		;y-position/8	
-;male 
-	.db 11		;object number
-	.db $80		;obj present flag
-	.db 4+2		;x-position/8
-	.db 19		;y-position/8	
-	
-											
-;obj list terminator:
-	.dw 0
-
-Map2Pal:
-	.incbin "data/levels/resultsmap.clr"
-Map2Col:
-;	.incbin "data/levels/map1coli.bmp" SKIP $3e
-Map2Tile:
-	.incbin "data/levels/resultsmap.pic" ;READ $7eb2		;$8000+32000+496
-Map2EOF:
-.ends
-
-
-.Section "level file 3" superfree
-Map3:
-	.db 28		;size in tiles, x
-	.db 26		;size in tiles, y
-	.db 0		;background color,r
-	.db 0		;background color,g
-	.db 0		;background color,b
-	.dw Map3Pal-Map3	;relative pointer(16bit) to palette
-	.dw Map3Col-Map3	;relative pointer(16bit) to collision map
-	.dw Map3Tile-Map3	;relative pointer(16bit) to image
-	.dw Map3EOF	;direct pointer(24bit) to EOF
-	.db (:Map3EOF)-(:Map3)+$c0
-	.dw Map3Exits-Map3
-;from here, total 19 additional bytes:
-	.dw Map3Objs-Map3
-Map3Exits:
-;exit 0:	
-
-;exit list terminator:	
-	.dw $0
-
-Map3Objs:
-/*
-;cpu usage
-	.db 1		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 00		;y-position/8
-*/
-;male 
-	.db 4		;object number
-	.db $80		;obj present flag
-	.db 2+2		;x-position/8
-	.db 6		;y-position/8
-;male 
-	.db 5		;object number
-	.db $80		;obj present flag
-	.db 4+2		;x-position/8
-	.db 6		;y-position/8
-;male 
-	.db 6		;object number
-	.db $80		;obj present flag
-	.db 6+2		;x-position/8
-	.db 6		;y-position/8
-;male 
-	.db 7		;object number
-	.db $80		;obj present flag
-	.db 8+2		;x-position/8
-	.db 8		;y-position/8
-;male 
-	.db 8		;object number
-	.db $80		;obj present flag
-	.db 10+2		;x-position/8
-	.db 10		;y-position/8		
-;male 
-	.db 9		;object number
-	.db $80		;obj present flag
-	.db 12+2		;x-position/8
-	.db 12		;y-position/8	
-;male 
-	.db 10		;object number
-	.db $80		;obj present flag
-	.db 14+2		;x-position/8
-	.db 14		;y-position/8	
-;male 
-	.db 11		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 16		;y-position/8	
-	
-;healthmeter
-	.db 12		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 1		;y-position/8	
-
-;healthmeter
-	.db 13		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 14		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 1		;y-position/8
-	
-;healthmeter
-	.db 15		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 16		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 21		;y-position/8
-
-;healthmeter
-	.db 17		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 18		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 19		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 21		;y-position/8												
-;obj list terminator:
-	.dw 0
-
-Map3Pal:
-;	.incbin "data/levels/map3.clr"
-Map3Col:
-;	.incbin "data/levels/map3coli.bmp" SKIP $3e
-Map3Tile:
-;	.incbin "data/levels/map3.pic" ;READ $7eb2		;$8000+32000+496
-Map3EOF:	
-.ends
-
-
-.Section "level file 4" superfree
-Map4:
-	.db 28		;size in tiles, x
-	.db 26		;size in tiles, y
-	.db 0		;background color,r
-	.db 0		;background color,g
-	.db 0		;background color,b
-	.dw Map4Pal-Map4	;relative pointer(16bit) to palette
-	.dw Map4Col-Map4	;relative pointer(16bit) to collision map
-	.dw Map4Tile-Map4	;relative pointer(16bit) to image
-	.dw Map4EOF	;direct pointer(24bit) to EOF
-	.db (:Map4EOF)-(:Map4)+$c0
-	.dw Map4Exits-Map4
-;from here, total 19 additional bytes:
-	.dw Map4Objs-Map4
-Map4Exits:
-;exit 0:	
-
-;exit list terminator:	
-	.dw $0
-
-Map4Objs:
-/*
-;cpu usage
-	.db 1		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 00		;y-position/8
-*/
-;male 
-	.db 4		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 5		;y-position/8
-;male 
-	.db 5		;object number
-	.db $80		;obj present flag
-	.db 18+2		;x-position/8
-	.db 5		;y-position/8
-;male 
-	.db 6		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 14		;y-position/8
-;male 
-	.db 7		;object number
-	.db $80		;obj present flag
-	.db 18+2		;x-position/8
-	.db 12		;y-position/8
-;male 
-	.db 8		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 20		;y-position/8		
-;male 
-	.db 9		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 19		;y-position/8	
-;male 
-	.db 10		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 18		;y-position/8	
-;male 
-	.db 11		;object number
-	.db $80		;obj present flag
-	.db 23+2		;x-position/8
-	.db 19		;y-position/8	
-	
-;healthmeter
-	.db 12		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 1		;y-position/8	
-
-;healthmeter
-	.db 13		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 14		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 1		;y-position/8
-	
-;healthmeter
-	.db 15		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 16		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 21		;y-position/8
-
-;healthmeter
-	.db 17		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 18		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 19		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 21		;y-position/8												
-;obj list terminator:
-	.dw 0
-
-Map4Pal:
-	.incbin "data/levels/map9.clr"
-Map4Col:
-	.incbin "data/levels/map9coli.bmp" SKIP $3e
-Map4Tile:
-	.incbin "data/levels/map9.pic" ;READ $7eb2		;$8000+32000+496
-Map4EOF:	
-.ends
-
-
-.Section "level file 5" superfree
-Map5:
-	.db 28		;size in tiles, x
-	.db 26		;size in tiles, y
-	.db 0		;background color,r
-	.db 0		;background color,g
-	.db 0		;background color,b
-	.dw Map5Pal-Map5	;relative pointer(16bit) to palette
-	.dw Map5Col-Map5	;relative pointer(16bit) to collision map
-	.dw Map5Tile-Map5	;relative pointer(16bit) to image
-	.dw Map5EOF	;direct pointer(24bit) to EOF
-	.db (:Map5EOF)-(:Map5)+$c0
-	.dw Map5Exits-Map5
-;from here, total 19 additional bytes:
-	.dw Map5Objs-Map5
-Map5Exits:
-;exit 0:	
-
-;exit list terminator:	
-	.dw $0
-
-Map5Objs:
-/*
-;cpu usage
-	.db 1		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 00		;y-position/8
-*/
-;male 
-	.db 4		;object number
-	.db $80		;obj present flag
-	.db 5+2		;x-position/8
-	.db 17		;y-position/8
-;male 
-	.db 5		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 14		;y-position/8
-;male 
-	.db 6		;object number
-	.db $80		;obj present flag
-	.db 5+2		;x-position/8
-	.db 9		;y-position/8
-;male 
-	.db 7		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 7		;y-position/8
-;male 
-	.db 8		;object number
-	.db $80		;obj present flag
-	.db 14+2		;x-position/8
-	.db 6		;y-position/8		
-;male 
-	.db 9		;object number
-	.db $80		;obj present flag
-	.db 20+2		;x-position/8
-	.db 7		;y-position/8	
-;male 
-	.db 10		;object number
-	.db $80		;obj present flag
-	.db 23+2		;x-position/8
-	.db 10		;y-position/8	
-;male 
-	.db 11		;object number
-	.db $80		;obj present flag
-	.db 24+2		;x-position/8
-	.db 14		;y-position/8	
-	
-;healthmeter
-	.db 12		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 1		;y-position/8	
-
-;healthmeter
-	.db 13		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 14		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 1		;y-position/8
-	
-;healthmeter
-	.db 15		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 16		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 21		;y-position/8
-
-;healthmeter
-	.db 17		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 18		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 19		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 21		;y-position/8												
-;obj list terminator:
-	.dw 0
-
-Map5Pal:
-	.incbin "data/levels/map5.clr"
-Map5Col:
-	.incbin "data/levels/map5coli.bmp" SKIP $3e
-Map5Tile:
-	.incbin "data/levels/map5.pic" ;READ $7eb2		;$8000+32000+496
-Map5EOF:
-.ends
-
-
-.Section "level file 6" superfree
-Map6:
-	.db 28		;size in tiles, x
-	.db 26		;size in tiles, y
-	.db 0		;background color,r
-	.db 0		;background color,g
-	.db 0		;background color,b
-	.dw Map6Pal-Map6	;relative pointer(16bit) to palette
-	.dw Map6Col-Map6	;relative pointer(16bit) to collision map
-	.dw Map6Tile-Map6	;relative pointer(16bit) to image
-	.dw Map6EOF	;direct pointer(24bit) to EOF
-	.db (:Map6EOF)-(:Map6)+$c0
-	.dw Map6Exits-Map6
-;from here, total 19 additional bytes:
-	.dw Map6Objs-Map6
-Map6Exits:
-;exit 0:	
-
-;exit list terminator:	
-	.dw $0
-
-Map6Objs:
-/*
-;cpu usage
-	.db 1		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 00		;y-position/8
-*/
-;male 
-	.db 4		;object number
-	.db $80		;obj present flag
-	.db 8+2		;x-position/8
-	.db 8		;y-position/8
-;male 
-	.db 5		;object number
-	.db $80		;obj present flag
-	.db 12+2		;x-position/8
-	.db 8		;y-position/8
-;male 
-	.db 6		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 8		;y-position/8
-;male 
-	.db 7		;object number
-	.db $80		;obj present flag
-	.db 20+2		;x-position/8
-	.db 8		;y-position/8
-;male 
-	.db 8		;object number
-	.db $80		;obj present flag
-	.db 4+2		;x-position/8
-	.db 19		;y-position/8		
-;male 
-	.db 9		;object number
-	.db $80		;obj present flag
-	.db 10+2		;x-position/8
-	.db 19		;y-position/8	
-;male 
-	.db 10		;object number
-	.db $80		;obj present flag
-	.db 17+2		;x-position/8
-	.db 19		;y-position/8	
-;male 
-	.db 11		;object number
-	.db $80		;obj present flag
-	.db 24+2		;x-position/8
-	.db 19		;y-position/8	
-	
-;healthmeter
-	.db 12		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 1		;y-position/8	
-
-;healthmeter
-	.db 13		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 14		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 1		;y-position/8
-	
-;healthmeter
-	.db 15		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 16		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 21		;y-position/8
-
-;healthmeter
-	.db 17		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 18		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 19		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 21		;y-position/8												
-;obj list terminator:
-	.dw 0
-
-Map6Pal:
-	.incbin "data/levels/map6.clr"
-Map6Col:
-	.incbin "data/levels/map6coli.bmp" SKIP $3e
-Map6Tile:
-	.incbin "data/levels/map6.pic" ;READ $7eb2		;$8000+32000+496
-Map6EOF:	
-.ends
-
-
-.Section "level file 7" superfree
-Map7:
-	.db 28		;size in tiles, x
-	.db 26		;size in tiles, y
-	.db 0		;background color,r
-	.db 0		;background color,g
-	.db 0		;background color,b
-	.dw Map7Pal-Map7	;relative pointer(16bit) to palette
-	.dw Map7Col-Map7	;relative pointer(16bit) to collision map
-	.dw Map7Tile-Map7	;relative pointer(16bit) to image
-	.dw Map7EOF	;direct pointer(24bit) to EOF
-	.db (:Map7EOF)-(:Map7)+$c0
-	.dw Map7Exits-Map7
-;from here, total 19 additional bytes:
-	.dw Map7Objs-Map7
-Map7Exits:
-;exit 0:	
-
-;exit list terminator:	
-	.dw $0
-
-Map7Objs:
-/*
-;cpu usage
-	.db 1		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 00		;y-position/8
-*/
-;male 
-	.db 4		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 15		;y-position/8
-;male 
-	.db 5		;object number
-	.db $80		;obj present flag
-	.db 5+2		;x-position/8
-	.db 20		;y-position/8
-;male 
-	.db 6		;object number
-	.db $80		;obj present flag
-	.db 10+2		;x-position/8
-	.db 20		;y-position/8
-;male 
-	.db 7		;object number
-	.db $80		;obj present flag
-	.db 14+2		;x-position/8
-	.db 4		;y-position/8
-;male 
-	.db 8		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 7		;y-position/8		
-;male 
-	.db 9		;object number
-	.db $80		;obj present flag
-	.db 17+2		;x-position/8
-	.db 10		;y-position/8	
-;male 
-	.db 10		;object number
-	.db $80		;obj present flag
-	.db 20+2		;x-position/8
-	.db 13		;y-position/8	
-;male 
-	.db 11		;object number
-	.db $80		;obj present flag
-	.db 24+2		;x-position/8
-	.db 15		;y-position/8	
-	
-;healthmeter
-	.db 12		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 1		;y-position/8	
-
-;healthmeter
-	.db 13		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 14		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 1		;y-position/8
-	
-;healthmeter
-	.db 15		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 16		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 21		;y-position/8
-
-;healthmeter
-	.db 17		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 18		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 19		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 21		;y-position/8												
-;obj list terminator:
-	.dw 0
-
-Map7Pal:
-	.incbin "data/levels/map7.clr"
-Map7Col:
-	.incbin "data/levels/map7coli.bmp" SKIP $3e
-Map7Tile:
-	.incbin "data/levels/map7.pic" ;READ $7eb2		;$8000+32000+496
-Map7EOF:	
-.ends
-
-
-
-
-.bank 12 slot 0
-.org $0
-.Section "nightsky"
-
-
-Map8:
-	.db 28		;size in tiles, x
-	.db 64		;size in tiles, y
-	.db 0		;background color,r
-	.db 0		;background color,g
-	.db 0		;background color,b
-	.dw Map8Pal-Map8	;relative pointer(16bit) to palette
-	.dw Map8Col-Map8	;relative pointer(16bit) to collision map
-	.dw Map8Tile-Map8	;relative pointer(16bit) to image
-	.dw Map8EOF	;direct pointer(24bit) to EOF
-	.db (:Map8EOF)-(:Map8)+$c0
-	.dw Map8Exits-Map8
-;from here, total 19 additional bytes:
-	.dw Map8Objs-Map8
-Map8Exits:
-;exit 0:	
-
-;exit list terminator:	
-	.dw $0
-
-Map8Objs:
-/*
-;cpu usage
-	.db 1		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 00		;y-position/8
-
-;mond 1 
-	.db 20		;object number
-	.db $00		;obj present flag
-	.db 3+2		;x-position/8
-	.db 15		;y-position/8
-;male 
-	.db 5		;object number
-	.db $00		;obj present flag
-	.db 5+2		;x-position/8
-	.db 20		;y-position/8
-;male 
-	.db 6		;object number
-	.db $80		;obj present flag
-	.db 10+2		;x-position/8
-	.db 23		;y-position/8
-;male 
-	.db 7		;object number
-	.db $80		;obj present flag
-	.db 14+2		;x-position/8
-	.db 3		;y-position/8
-;male 
-	.db 8		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 7		;y-position/8		
-;male 
-	.db 9		;object number
-	.db $80		;obj present flag
-	.db 17+2		;x-position/8
-	.db 10		;y-position/8	
-;male 
-	.db 10		;object number
-	.db $80		;obj present flag
-	.db 20+2		;x-position/8
-	.db 13		;y-position/8	
-;male 
-	.db 11		;object number
-	.db $80		;obj present flag
-	.db 24+2		;x-position/8
-	.db 15		;y-position/8	
-	
-;healthmeter
-	.db 12		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 1		;y-position/8	
-
-;healthmeter
-	.db 13		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 14		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 1		;y-position/8
-	
-;healthmeter
-	.db 15		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 16		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 21		;y-position/8
-
-;healthmeter
-	.db 17		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 18		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 19		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 21		;y-position/8	
-*/												
-;obj list terminator:
-	
-
-Map8Pal:
-	.incbin "data/levels/nightsky.clr"
-	
-	
-Map8Col:
-;	.incbin "data/levels/map8coli.bmp" SKIP $3e
-
-.incbin "data/levels/dummy.bin"	
-.dw 0
-.dw 0
-Map8Tile:
-	.incbin "data/levels/nightsky.pic" READ $f500		;$8000+32000+496
-
-.ends
-
-.bank 13 slot 0
-.org $0
-.Section "nightsky 2"
-
-	.incbin "data/levels/nightsky.pic" SKIP $f500 READ $cb00	;$8000+32000+496
-
-Map8EOF:	
-.ends
-
-
-
-
-.Section "level file 9" superfree
-Map9:
-	.db 28		;size in tiles, x
-	.db 26		;size in tiles, y
-	.db 0		;background color,r
-	.db 0		;background color,g
-	.db 0		;background color,b
-	.dw Map9Pal-Map9	;relative pointer(16bit) to palette
-	.dw Map9Col-Map9	;relative pointer(16bit) to collision map
-	.dw Map9Tile-Map9	;relative pointer(16bit) to image
-	.dw Map9EOF	;direct pointer(24bit) to EOF
-	.db (:Map9EOF)-(:Map9)+$c0
-	.dw Map9Exits-Map9
-;from here, total 19 additional bytes:
-	.dw Map9Objs-Map9
-Map9Exits:
-;exit 0:	
-
-;exit list terminator:	
-	.dw $0
-
-Map9Objs:
-/*
-;cpu usage
-	.db 1		;object number
-	.db $80		;obj present flag
-	.db 16+2		;x-position/8
-	.db 00		;y-position/8
-*/
-;male 
-	.db 4		;object number
-	.db $80		;obj present flag
-	.db 4+2		;x-position/8
-	.db 2		;y-position/8
-;male 
-	.db 5		;object number
-	.db $80		;obj present flag
-	.db 4+2		;x-position/8
-	.db 6		;y-position/8
-;male 
-	.db 6		;object number
-	.db $80		;obj present flag
-	.db 4+2		;x-position/8
-	.db 10		;y-position/8
-;male 
-	.db 7		;object number
-	.db $80		;obj present flag
-	.db 4+2		;x-position/8
-	.db 14		;y-position/8
-;male 
-	.db 8		;object number
-	.db $80		;obj present flag
-	.db 4+2		;x-position/8
-	.db 18		;y-position/8		
-;male 
-	.db 9		;object number
-	.db $80		;obj present flag
-	.db 4+2		;x-position/8
-	.db 22		;y-position/8	
-;male 
-	.db 10		;object number
-	.db $80		;obj present flag
-	.db 6+2		;x-position/8
-	.db 18		;y-position/8	
-;male 
-	.db 11		;object number
-	.db $80		;obj present flag
-	.db 6+2		;x-position/8
-	.db 22		;y-position/8	
-	
-;healthmeter
-	.db 12		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 1		;y-position/8	
-
-;healthmeter
-	.db 13		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 14		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 1		;y-position/8
-	
-;healthmeter
-	.db 15		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 1		;y-position/8
-
-;healthmeter
-	.db 16		;object number
-	.db $80		;obj present flag
-	.db 3+2		;x-position/8
-	.db 21		;y-position/8
-
-;healthmeter
-	.db 17		;object number
-	.db $80		;obj present flag
-	.db 9+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 18		;object number
-	.db $80		;obj present flag
-	.db 15+2		;x-position/8
-	.db 21		;y-position/8
-	
-;healthmeter
-	.db 19		;object number
-	.db $80		;obj present flag
-	.db 21+2		;x-position/8
-	.db 21		;y-position/8												
-;obj list terminator:
-	.dw 0
-
-Map9Pal:
-	.incbin "data/levels/debugmap.clr"
-Map9Col:
-	.incbin "data/levels/debugmap.bmp" SKIP $3e
-	.db 0
-Map9Tile:
-	.incbin "data/levels/debugmap.pic" ;READ $7eb2		;$8000+32000+496
-Map9EOF:	
-	
-.ends

+ 0 - 160
snes/loader/routines/memoryclear.asm

@@ -1,160 +0,0 @@
-/*
-;partially clears wram to predefined value
-;in: 	a,8bit: number of word to clear memory with. 
-;		x,16bit: target word adress in wram bank $7e
-;		y,16bit: transfer length
-;how to use:
-	rep #$31
-	sep #$20
-	lda.b #0		;clear word: $0000
-	ldy.w #$200
-	ldx.w #PaletteBuffer&$ffff
-	jsr ClearWRAM
-*/	
-	
-ClearWRAM:
-   php
-   phb
-   sep #$20
-   pha
-   lda.b #$80
-   pha
-   plb
-   pla
-   REP #$31		; mem/A = 8 bit, X/Y = 16 bit
-   
-   and.w #$7	;calculate adress of clear pattern word(8 entries max)
-   asl a
-   adc.w #ClearWramBytePatterns
-   sta.w $4312	;dma source
-   
-   SEP #$20
-
-   lda.b #(:ClearWramBytePatterns+BaseAdress>>16)
-   STA $4314         ;Set source bank to $00
-   
-   stx.w $2181	;store target wram adress in bank $7e
-   stz.w $2183	;bank $7e
-
-   LDX #$800a
-   STX $4310         ;Set DMA mode to fixed source, WORD to $2180
-
-   sty.w $4315         ;Set transfer size
-   LDA #$02
-   STA $420B         ;Initiate transfer
-   plb
-   plp
-   RTS
-
-;byte patterns to clear wram with.(8 entries max)   
-ClearWramBytePatterns:
-	.dw 0			;zeros
-	.dw $eaea		;nops
-	.dw $2480		;bg3 tilemap clear word
-	.dw $00c9		;oam buffer
-	.dw $2907		;bg1 tilemap clear
-
-;clears whole vram   
-ClearVRAM:
-   pha
-   phx
-   php
-   REP #$30		; mem/A = 8 bit, X/Y = 16 bit
-   SEP #$20
-   
-   LDA #$80
-   sta.w $2100			;set blanking active
-   stz.w $4200			;disable irqs
-   STA $2115         ;Set VRAM port to word access
-   LDX #$1809
-   STX $4310         ;Set DMA mode to fixed source, WORD to $2118/9
-   LDX #$0000
-   STX $2116         ;Set VRAM port address to $0000
-   STX $0000         ;Set $00:0000 to $0000 (assumes scratchpad ram)
-   STX $4312         ;Set source address to $xx:0000
-   LDA #$00
-   STA $4314         ;Set source bank to $00
-   LDX #$FFFF
-   STX $4315         ;Set transfer size to 64k-1 bytes
-   LDA #$02
-   STA $420B         ;Initiate transfer
-   STZ $2119         ;clear the last byte of the VRAM
-   lda.b ScreenBrightness
-   sta.w $2100				;reenable screen and irqs
-   lda.b InterruptEnableFlags
-   sta.w $4200
-   plp
-   plx
-   pla
-   RTS
-
-;copy random data to wram
-;in:	TempBuffer0-2 - source pointer
-;			x							- wram bank $7e target
-;			y							- transfer length							
-DmaToWRAM:
-   php
-   phb
-   sep #$20
-   pha
-   lda.b #$80
-   pha
-   plb
-   pla
-   REP #$31		; mem/A = 8 bit, X/Y = 16 bit
-   
-	 lda.b TempBuffer
-   sta.w $4312	;dma source
-   
-   SEP #$20
-
-   lda.b TempBuffer+2
-   STA $4314         ;Set source bank to $00
-   
-   stx.w $2181	;store target wram adress in bank $7e
-   stz.w $2183	;bank $7e
-
-   LDX #$8002
-   STX $4310         ;Set DMA mode to inc source, WORD to $2180
-
-   sty.w $4315         ;Set transfer size
-   LDA #$02
-   STA $420B         ;Initiate transfer
-   plb
-   plp
-   RTS
-
-;uploads 1 hirom bank to ram bank $7f  
-ROMToWRAM:
-   php
-   phb
-   sep #$20
-   pha
-   lda.b #$80
-   pha
-   plb
-   pla
-   REP #$31		; mem/A = 8 bit, X/Y = 16 bit
-   
-	stz.w $4315         ;Set transfer size
-   stz.w $4312	;dma source
-   stz.w $2181	;$7f0000
-   SEP #$20
-
-   lda.b #$c0
-   STA $4314         ;Set source bank to $00
-   
-   lda.b #1
-   sta.w $2183	;bank $7e
-
-   LDX #$8002
-   STX $4310         ;Set DMA mode to inc source, WORD to $2180
-
-   
-   LDA #$02
-   STA $420B         ;Initiate transfer
-   plb
-   plp
-   RTS   
-   
-   

+ 0 - 320
snes/loader/routines/menufiles.asm

@@ -1,320 +0,0 @@
-.Section "menu files" superfree
-/*
-these are the menu files for menusystem.asm
-
-menu table format:
-byte		function
-2		starting position of first option text on bg3 tilemap
-1		relative starting position of first option variable(*2+starting position of first option text on bg3 tilemap)
-1		number of seperating rows between options
-1		number of rows/options
-2xrow quantity	relative pointer to data for each row
-
-
-row table format:
-1		option data type (maximum number:7)
-		0x0=no options, only exec subroutine
-		0x1=1 byte
-		0x2=8 bits
-		0x3=interchangeable options with description text (eg: "sound: mono/stereo) . number of options is variable and limited by the bitmask
-		0x4=3byte adress with individual control over each byte(not implemented yet)
-1		bitmask for changeable bits if data type=0x2; bitmask(usually only one bit) to determine the string to choose if data type=0x3(if zero=string 1, if not zero=string 2)
-1		minimum value for option, wrap to maximum value if changed value equals this
-1		maximum value for option, wrap to minimum value if changed value equals this
-3		24bit adress of option byte to change
-1		Number of subroutine to execute when option is changed(number can be found in MenuSubroutineLUT)
-1		palette number when unselected
-1		palette number when selected
-2xstring quant.	relative pointer to text string
-x		option text string(s), #$00 terminated
-
-
-*/
-MenuFilesPTable:
-	.dw MenuFile0
-	.dw MenuFile1
-	.dw MenuFile2
-
-
-MenuFiles:
-MenuFile0:
-	.dw $0306			;starting position of first option text on bg3 tilemap
-	.db 16				;relative starting position of first option variable
-	.db 0				;number of seperating rows between options
-	.db 6				;number of rows/options
-	.dw (MenuFile0Row0-MenuFile0)
-	.dw (MenuFile0Row1-MenuFile0)
-	.dw (MenuFile0Row2-MenuFile0)
-	.dw (MenuFile0Row3-MenuFile0)
-	.dw (MenuFile0Row4-MenuFile0)
-	.dw (MenuFile0Row5-MenuFile0)
-
-
-	MenuFile0Row0:
-		.db 0				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db $ff				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw CurrentLevel		;24bit adress of option byte to change
-		.db $7E
-		.db 1				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile0Row0String0-MenuFile0)
-		MenuFile0Row0String0:
-			.db "Jump to ROM"
-			.db $00				;terminator
-
-	MenuFile0Row1:
-		.db 0				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db $ff				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw CurrentBattleFile				;24bit adress of option byte to change
-		.db $7e
-		.db 2				;2 ;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile0Row1String0-MenuFile0)
-		MenuFile0Row1String0:
-			.db "Jump to RAM"
-			.db $00				;terminator
-
-	MenuFile0Row2:
-		.db 3				;option data type (maximum number:7)
-		.db 7				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db 1				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw IrqRoutineNumberBuffer				;24bit adress of option byte to change
-		.db $7e
-		.db 0				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile0Row2String0-MenuFile0)
-		.dw (MenuFile0Row2String1-MenuFile0)
-		.dw (MenuFile0Row2String2-MenuFile0)
-
-		MenuFile0Row2String0:
-			.db "Video-IRQ"
-			.db $00				;terminator		
-
-		MenuFile0Row2String1:
-			.db "Disable"
-			.db $00				;terminator		
-
-		MenuFile0Row2String2:
-			.db "Enable "
-			.db $00				;terminator		
-
-
-	MenuFile0Row3:
-		.db 1				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db $ff				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw Reg3000WriteVar				;24bit adress of option byte to change
-		.db $7e
-		.db 4				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile0Row3String0-MenuFile0)
-		MenuFile0Row3String0:
-			.db "$00:3000 Write"
-			.db $00				;terminator
-
-
-	MenuFile0Row4:
-		.db 0				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db 31				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw PtPlayerCurrentSoundEffect				;24bit adress of option byte to change
-		.db $7e
-		.db 3				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile0Row4String0-MenuFile0)
-		MenuFile0Row4String0:
-			.db "Audio Menu"
-			.db $00				;terminator
-
-	MenuFile0Row5:
-		.db 0				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db $7f				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw SpcSEVolume				;24bit adress of option byte to change
-		.db $7e
-		.db 12				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile0Row5String0-MenuFile0)
-		MenuFile0Row5String0:
-			.db "Calc Chsum"
-			.db $00				;terminator
-
-
-		
-			
-			
-;audio menu
-MenuFile1:
-	.dw $0306			;starting position of first option text on bg3 tilemap
-	.db 20				;relative starting position of first option variable
-	.db 0				;number of seperating rows between options
-	.db 6				;number of rows/options
-	.dw (MenuFile1Row2-MenuFile1)
-	.dw (MenuFile1Row7-MenuFile1)
-	.dw (MenuFile1Row8-MenuFile1)
-	.dw (MenuFile1Row9-MenuFile1)
-	.dw (MenuFile1Row10-MenuFile1)
-	.dw (MenuFile1Row11-MenuFile1)
-
-
-
-
-	MenuFile1Row2:
-		.db 0				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db 0				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw PtPlayerCurrentSong				;24bit adress of option byte to change
-		.db $7e
-		.db 5				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile1Row2String0-MenuFile1)
-		MenuFile1Row2String0:
-			.db "Upload,play song"
-			.db $00				;terminator
-
-
-
-	MenuFile1Row7:
-		.db 0				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db 59				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw SpcSEPitch				;24bit adress of option byte to change
-		.db $7e
-		.db 8				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile1Row7String0-MenuFile1)
-		MenuFile1Row7String0:
-			.db "Stop song"
-			.db $00				;terminator						
-			
-
-	MenuFile1Row8:
-		.db 1				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db $ff				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw SpcSongSpeed				;24bit adress of option byte to change
-		.db $7e
-		.db 9				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile1Row8String0-MenuFile1)
-		MenuFile1Row8String0:
-			.db "Set song speed"
-			.db $00				;terminator		
-			
-
-	MenuFile1Row9:
-		.db 2				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db $0f				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw SpcSongChMask				;24bit adress of option byte to change
-		.db $7e
-		.db 10				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile1Row9String0-MenuFile1)
-		MenuFile1Row9String0:
-			.db "Song channel mask"
-			.db $00				;terminator						
-			
-			
-	MenuFile1Row10:
-		.db 3				;option data type (maximum number:7)
-		.db 7				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db 7				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw SpcReportType				;24bit adress of option byte to change
-		.db $7e
-		.db 11				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile1Row10String0-MenuFile1)
-		.dw (MenuFile1Row10String1-MenuFile1)
-		.dw (MenuFile1Row10String2-MenuFile1)
-		.dw (MenuFile1Row10String3-MenuFile1)
-		.dw (MenuFile1Row10String4-MenuFile1)
-		.dw (MenuFile1Row10String1-MenuFile1)
-		.dw (MenuFile1Row10String1-MenuFile1)
-		.dw (MenuFile1Row10String1-MenuFile1)
-		.dw (MenuFile1Row10String1-MenuFile1)
-		MenuFile1Row10String0:
-			.db "Spc Report Type"
-			.db $00				;terminator		
-
-		MenuFile1Row10String1:
-			.db "None    "
-			.db $00				;terminator		
-
-		MenuFile1Row10String2:
-			.db "Timecode"
-			.db $00				;terminator		
-
-		MenuFile1Row10String3:
-			.db "Vol Out "
-			.db $00				;terminator		
-
-		MenuFile1Row10String4:
-			.db "Mod Cmd "
-			.db $00				;terminator										
-			
-	MenuFile1Row11:
-		.db 0				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db $0f				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw SpcSongChMask				;24bit adress of option byte to change
-		.db $7e
-		.db 13				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile1Row11String0-MenuFile1)
-		MenuFile1Row11String0:
-			.db "Return"
-			.db $00		
-			
-MenuFile2:
-	.dw $0306			;starting position of first option text on bg3 tilemap
-	.db 16				;relative starting position of first option variable
-	.db 0				;number of seperating rows between options
-	.db 1				;number of rows/options
-	.dw (MenuFile2Row0-MenuFile2)
-
-	MenuFile2Row0:
-		.db 0				;option data type (maximum number:7)
-		.db 0				;bitmask for changeable bits
-		.db 0				;minimum value for option, wrap to maximum value if changed value equals this
-		.db $ff				;maximum value for option, wrap to minimum value if changed value equals this
-		.dw CurrentLevel		;24bit adress of option byte to change
-		.db $7E
-		.db 13				;number of subroutine to execute
-		.db 1				;palette number when unselected
-		.db 0				;palette number when selected
-		.dw (MenuFile2Row0String0-MenuFile2)
-		MenuFile2Row0String0:
-			.db "Return"
-			.db $00				;terminator					
-			
-			
-			
-
-.ends			

+ 0 - 174
snes/loader/routines/menusubroutines.asm

@@ -1,174 +0,0 @@
-MenuSubroutineLUT:
-	.dw MenuSubroutineVoid			;0
-	.dw MenuSubroutineJumpROM
-;	.dw MenuSubroutineLoadBattle
-	.dw MenuSubroutineJumpRAM
-	.dw MenuSubroutineAudioMenu
-
-	.dw MenuSubroutineWrite3000
-	.dw MenuSubroutinePlaySong		;5
-	.dw MenuSubroutineUploadSEPack
-	.dw MenuSubroutinePlaySE
-	.dw SpcStopSong				
-	.dw SpcSetSongSpeed
-	.dw SpcSetSongChannelMask		;10
-	.dw SpcSetReportType
-	.dw MenuSubroutineChsum
-	.dw MenuSubroutineReturnMain
-	.dw MenuSubroutineTablistRecorder
-	.dw MenuSubroutineExecTablistRec	;15
-	.dw MenuSubroutinePlayTablist
-	.dw MenuSubroutineDelTablist
-	.dw MenuSubroutineLoadDebugmap
-	.dw MenuSubroutineLoadCredits
-
-MenuSubroutineChsum:
-	sep #$20
-	phk
-	pla
-	sta.b TempBuffer+2			;operating bank
-	
-	rep #$31
-	stz.b TempBuffer
-	stz.w CartChecksum
-
-	
-	ldy.w #0
-WramChecksumLoop:
-	rep #$31
-	lda.b [TempBuffer],y
-	and.w #$ff
-	adc.w CartChecksum
-	sta.w CartChecksum
-	iny
-	bne WramChecksumLoop
-	
-	ldy.w #$ffde
-	lda.b [TempBuffer],y
-	cmp.w CartChecksum
-	beq WramChecksumOK
-
-	ldx.w #17
-	jsr LoadTextString		;print $00:3000	
-	rts
-
-WramChecksumOK:
-	ldx.w #16
-	jsr LoadTextString		;print $00:3000
-	rts
-
-MenuSubroutineJumpROM:
-	jml (MenuSubroutineJumpReturn+BaseAdress)
-MenuSubroutineJumpRAM:
-	jml (MenuSubroutineJumpReturn+$7f0000)
-
-MenuSubroutineJumpReturn:
-	rts
-
-MenuSubroutineWrite3000:
-	sep #$20
-	lda.w Reg3000WriteVar
-	sta.l $3000
-	rts
-	
-MenuSubroutineExecTablistRec:
-	sep #$20
-	lda.b #2
-	sta.b BattleMusicState
-	rts
-MenuSubroutinePlayTablist:
-	sep #$20
-	lda.b #4
-	sta.b BattleMusicState
-	rts
-	
-MenuSubroutineDelTablist:
-	sep #$20
-	stz.b BattleMusicState			;just init the whole tablist fsm 
-	rts
-	
-MenuSubroutineStartStream:
-	lda.b SpcCurrentStreamSet
-	jsr SpcPlayStream
-	rts
-MenuSubroutinePlaySong:
-	lda.b PtPlayerCurrentSong			;play song
-	jsr SpcPlaySong
-	rts
-MenuSubroutineUploadSEPack:
-	sep #$20
-	lda.b PtPlayerCurrentSamplePack
-	jsr SpcIssueSamplePackUpload
-	rts
-MenuSubroutinePlaySE:
-	sep #$20
-	lda.w SpcSEVolume
-	xba
-	lda.w SpcSEPitch
-	rep #$31
-	tax
-	sep #$20
-	lda.b PtPlayerCurrentSoundEffect
-	jsr SpcPlaySoundEffect
-	rts
-
-
-
-MenuSubroutineVoid:
-	rts
-
-MenuSubroutineReturnMain:
-	sep #$20
-	lda.b #0
-	sta.b CurrentEvent
-	rts
-
-MenuSubroutineTablistRecorder:
-	sep #$20
-	lda.b #10
-	sta.b CurrentEvent
-	rts
-	
-MenuSubroutineInputMenu:
-	sep #$20
-	lda.b #8
-	sta.b CurrentEvent
-	rts
-
-MenuSubroutineAudioMenu:
-	sep #$20
-	lda.b #2
-	sta.b CurrentEvent
-	rts
-
-MenuSubroutineLoadLevel:
-	sep #$20
-	lda.b #4
-	sta.b CurrentEvent
-	rts
-
-MenuSubroutineLoadBattle:
-	sep #$20
-	lda.b #2
-	sta.b CurrentEvent
-	rts
-
-MenuSubroutineLoadIntro:
-	sep #$20
-	lda.b #28
-	sta.b CurrentEvent
-	rts
-
-MenuSubroutineLoadDebugmap:
-	sep #$20
-	lda.b #37
-	sta.b CurrentEvent
-	rts
-
-MenuSubroutineLoadCredits:
-	sep #$20
-	lda.b #36
-	sta.b CurrentEvent
-;	stz.b ScreenBrightness
-	rts	
-	

+ 0 - 706
snes/loader/routines/menusystem.asm

@@ -1,706 +0,0 @@
-/*
-tiny menu system for snes by d4s in 2006
-depends on:
-printstring.asm, function: LoadTextString
-
-execute with:
-ldx.w #number_of_menu_file_to_load
-jsr LoadMenuFile
-
-
-
-features:
--1 column, x rows
--seperate bytes and bits manipulation
--print text and menu options with palette highlighting
--subroutine jump upon option change
--load complete menu from table, no hardcoded stuff
--menus tables should be compressable, relative pointers only!
-
-menu table format:
-byte		function
-2		starting position of first option text on bg3 tilemap
-1		relative starting position of first option variable(*2+starting position of first option text on bg3 tilemap)
-1		number of seperating rows between options
-1		number of rows/options
-2xrow quantity	relative pointer to data for each row
-
-
-row table format:
-1		option data type (maximum number:7)
-		0x0=no options, only exec subroutine
-		0x1=1 byte
-		0x2=8 bits
-		0x3=2 interchangeable options with description text (eg: "sound: mono/stereo)
-1		bitmask for changeable bits if data type=0x2; bitmask(usually only one bit) to determine the string to choose if data type=0x3(if zero=string 1, if not zero=string 2)
-1		minimum value for option, wrap to maximum value if changed value equals this
-1		maximum value for option, wrap to minimum value if changed value equals this
-3		24bit adress of option byte to change
-1		number of subroutine to execute when option is changed(push status and registers before executing)
-1		palette number when unselected
-1		palette number when selected
-1		number of option text strings(max=3, AND with 0x3)
-2xstring quant.	relative pointer to text string
-x		option text string(s), #$00 terminated
-
-processing flow:
-1. setup pointer to menu file
-2. load all general menu options and save to variables
-3. process and draw each option string onto screen once
- -setup pointer to row table
- -draw each option with corresponding option value once
-4. go to first option
- -if up pressed, redraw current line in unselected, decrease current line, redraw new current line in selected
- -if down pressed, redraw current line in unselected, increase current line, redraw new current line in selected
- 
- -if right pressed, increase options variable pointer
- -if left pressed, decrease options variable pointer
- 
-
-data files:
-MenuFiles
-
-
-Pointer Tables
-MenuFilesPTable
-
-variables:
-MenuFileThreeBytePointerLo
-MenuFileThreeBytePointerHi
-MenuFileThreeBytePointerBank
-MenuRowsThreeBytePointerLo
-MenuRowsThreeBytePointerHi
-MenuRowsThreeBytePointerBank
-MenuRowsThreeByteOptionPointerLo
-MenuRowsThreeByteOptionPointerHi
-MenuRowsThreeByteOptionPointerBank
-MenuRowsThreeByteCodePointerLo
-MenuRowsThreeByteCodePointerHi
-MenuRowsThreeByteCodePointerBank
-LoadMenuInitialOffset
-LoadMenuInitialOptionOffset
-LoadMenuVerticalSpacing
-LoadMenuNumberOfRows
-LoadMenuCurrentRow
-LoadMenuStringPosLo
-
-
-ram areas:
-LoadMenuStringBuffer(16bytes)
-
-string printing area, 16 bytes:
-0 - LoadMenuStringBuffer
-1 - LoadMenuStringSetOff		;always #$01, set new position
-2 - LoadMenuStringPosLo		;position of string
-3 - LoadMenuStringPosHi
-4 - LoadMenuStringSetPal		;always #$07, set palette
-5 - LoadMenuStringPal		;palette number
-6 - LoadMenuStringNewAddr		;draw variable length string, always #$04
-7 - LoadMenuStringVectLo
-8 - LoadMenuStringVectHi
-9 - LoadMenuStringVectBa
-a - LoadMenuStringSetOff2
-b - LoadMenuStringPosLo2		;position of string
-c - LoadMenuStringPosHi2
-d - LoadMenuStringByte/binary/string
-
-
-
-
-;this is the textstring for the text buffer of the menu system
-TextString20:
-	.dw $0000				;offset on bg1 tilemap
-	.db $04					;terminator
-	.dw LoadMenuStringBuffer
-	.db $7e
-
-
-*/
-
-
-
-
-LoadMenuFile:
-	php
-	sep #$20
-	phb					;set data bank = wram
-	lda.b #$7e
-	pha
-	plb
-	lda.b LoadMenuDoInit			;check if menu was already initialized
-	bne LoadMenuFileAlreadyInitialized
-
-	lda #(:MenuFiles+BaseAdress>>16)			;get source bank of strings
-	sta MenuFileThreeBytePointerBank		;
-	rep #$30				;accu 16bit
-	txa					;get number of string
-	asl					;multiply by 2 to get pointertable entry
-	tax
-	lda.l (MenuFilesPTable+BaseAdress),x			;get source offset of string
-	sta MenuFileThreeBytePointerLo
-	ldy.w #$0000
-
-	lda [MenuFileThreeBytePointerLo],y		;get target buffer in wram
-	iny					;increment source position, word
-	iny			
-	and.w #$fffe				;mask off bit 0 to ensure text is word-formatted properly
-	sta.b LoadMenuInitialOffset
-
-
-	lda.b [MenuFileThreeBytePointerLo],y	;get option position
-	iny
-	clc		
-	sep #$20
-	asl a
-	sta.b LoadMenuInitialOptionOffset	;store in variable
-
-	lda.b [MenuFileThreeBytePointerLo],y	;get vertical spacing position
-	iny
-	and.b #$0f				;maximum range:16
-	inc a
-	tax
-	lda.b #$00
-
-LoadMenuCalcVerticalSpacingLoop:
-	clc
-	adc.b #$40
-	dex
-	bne LoadMenuCalcVerticalSpacingLoop	;add one tileline for every loop, but do it at least once
-	sta.b LoadMenuVerticalSpacing
-
-	lda.b [MenuFileThreeBytePointerLo],y	;get number of rows/options
-	iny
-	and.b #$1f				;maximum number:32
-	bne LoadMenuNumberOfRowsNotZero
-	
-	plb					;exit if number of rows=0
-	plp
-	rts
-	
-LoadMenuNumberOfRowsNotZero:	
-	sta.b LoadMenuNumberOfRows
-	stz.b LoadMenuCurrentRow		;start processing at first row
-	stz.b LoadMenuPalUnselSel		;draw unselected palette
-	
-LoadMenuInitialOptionDrawLoop:	
-	jsr LoadMenuSetupRowPointer
-	jsr LoadMenuDrawDescString
-	jsr LoadMenuDrawOptionValue
-
-	sep #$20
-	lda.b LoadMenuCurrentRow
-	inc a
-	sta.b LoadMenuCurrentRow
-	cmp.b LoadMenuNumberOfRows
-	bne LoadMenuInitialOptionDrawLoop
-
-	stz.b LoadMenuCurrentRow		;start at row 1
-	inc.b LoadMenuDoInit			;store "menu initialized"
-
-	lda.b #$01
-	sta.b LoadMenuPalUnselSel		;draw first row highlighted
-	jsr LoadMenuSetupRowPointer
-	jsr LoadMenuDrawDescString
-	jsr LoadMenuDrawOptionValue
-
-
-LoadMenuFileAlreadyInitialized:
-	sep #$20
-	jsr LoadMenuSetupRowPointer
-	jsr LoadMenuDrawOptionValue
-	rep #$31
-	lda.w JoyPortBufferTrigger&$ffff
-	ldx.w #$ffff				;clear number of loaded button-1
-
-LoadMenuFileCheckNextButton:	
-	inx
-	cpx.w #$0010				;check if all buttons have been checked
-	beq LoadMenuFileCheckNextButtonDone
-	lsr a					;start at button bit 0
-	bcc LoadMenuFileCheckNextButton
-	
-	pha
-	phx
-	txa
-	clc
-	asl a
-	tax
-	jsr (LoadMenuFileCheckNextButtonJumpTbl,x)
-	
-	plx
-	pla
-	bra LoadMenuFileCheckNextButton
-
-
-
-LoadMenuFileCheckNextButtonDone:	
-
-
-
-	plb					;exit if number of rows=0
-	plp
-	rts
-
-
-LoadMenuFileCheckNextButtonJumpTbl:
-	.dw LoadMenuButtonVoid
-	.dw LoadMenuButtonVoid
-	.dw LoadMenuButtonVoid
-	.dw LoadMenuButtonVoid
-	.dw LoadMenuButtonVoid			;r
-	.dw LoadMenuButtonVoid			;l
-	.dw LoadMenuButtonVoid			;x
-	.dw LoadMenuExecuteSubroutine		;a
-	.dw LoadMenuIncreaseOption		;right
-	.dw LoadMenuDecreaseOption		;left
-	.dw LoadMenuIncreaseRow			;down
-	.dw LoadMenuDecreaseRow			;up
-	.dw LoadMenuButtonVoid			;start
-	.dw LoadMenuButtonVoid			;select
-	.dw LoadMenuButtonVoid			;a
-	.dw LoadMenuButtonVoid			;b
-
-	.dw LoadMenuButtonVoid
-
-LoadMenuButtonVoid:
-	rts
-
-LoadMenuIncreaseRow:
-	php
-	rep #$31
-	sep #$20
-
-	stz.b LoadMenuPalUnselSel		;draw current row unselected
-	jsr LoadMenuSetupRowPointer
-	jsr LoadMenuDrawDescString
-	jsr LoadMenuDrawOptionValue
-
-	lda.b LoadMenuCurrentRow
-	inc a
-	cmp.b LoadMenuNumberOfRows
-	bcc LoadMenuIncreaseRowNoOverflow
-
-	lda.b #$00				;wrap around to zero if maximum number of options is reached
-LoadMenuIncreaseRowNoOverflow:
-	sta.b LoadMenuCurrentRow
-	lda.b #$01
-	sta.b LoadMenuPalUnselSel		;draw current row
-	jsr LoadMenuSetupRowPointer
-	jsr LoadMenuDrawDescString
-	jsr LoadMenuDrawOptionValue
-
-	plp
-	rts
-
-LoadMenuDecreaseRow:
-	php
-	rep #$31
-	sep #$20
-
-	stz.b LoadMenuPalUnselSel		;draw current row unselected
-	jsr LoadMenuSetupRowPointer
-	jsr LoadMenuDrawDescString
-	jsr LoadMenuDrawOptionValue
-
-	lda.b LoadMenuCurrentRow
-	dec a
-	bpl LoadMenuIncreaseRowNoOverflow
-
-	lda.b LoadMenuNumberOfRows				;wrap around to highest row if minimum number of options is reached
-	dec a
-LoadMenuDecreaseRowNoOverflow:
-	sta.b LoadMenuCurrentRow
-	lda.b #$01
-	sta.b LoadMenuPalUnselSel		;draw current row
-	jsr LoadMenuSetupRowPointer
-	jsr LoadMenuDrawDescString
-	jsr LoadMenuDrawOptionValue
-
-	plp
-	rts
-
-LoadMenuIncreaseOption:
-	phy
-	php
-	rep #$31
-	sep #$20
-	jsr LoadMenuSetupRowPointer
-	ldy.w #$0000
-	lda.b [MenuRowsThreeBytePointerLo],y	;do nothing if were processing a subroutine-only option
-	bne LoadMenuIncreaseOptionNoEnd
-	
-	plp
-	ply
-	rts
-	
-LoadMenuIncreaseOptionNoEnd:
-	ldy.w #$0000
-	lda.b [MenuRowsThreeByteOptionPointerLo],y	;get byte, increase it and compare if its greater than the maximum value
-	ldy.w #$0003
-	cmp.b [MenuRowsThreeBytePointerLo],y
-	bcc LoadMenuIncreaseOptionNoOverflow
-	
-	dey
-	lda.b [MenuRowsThreeBytePointerLo],y	;get minimum value if wrap around
-	dec a
-			
-LoadMenuIncreaseOptionNoOverflow:
-	ldy.w #$0000
-	inc a
-	sta.b [MenuRowsThreeByteOptionPointerLo],y	;save back changed value
-
-;	ldy.w #0
-	lda.b [MenuRowsThreeBytePointerLo],y
-	cmp.b #1
-	bne LoadMenuIncNoByte				;only check for b if we're processing a byte-option
-
-	lda.w JoyPortBufferTrigger&$ffff+1
-	bpl LoadMenuIncNoByte
-
-	clc
-	lda.b [MenuRowsThreeByteOptionPointerLo],y	;save back changed value
-	adc.b #$f					;add a whole nibble if b is pressed
-	sta.b [MenuRowsThreeByteOptionPointerLo],y
-
-LoadMenuIncNoByte:	
-	lda.b #$01
-	sta.b LoadMenuPalUnselSel		;redraw current option
-	jsr LoadMenuDrawDescString
-	jsr LoadMenuDrawOptionValue
-	plp
-	ply
-	rts
-
-LoadMenuDecreaseOption:
-	phy
-	php
-	rep #$31
-	sep #$20
-	jsr LoadMenuSetupRowPointer
-	ldy.w #$0000
-	lda.b [MenuRowsThreeBytePointerLo],y	;do nothing if were processing a subroutine-only option
-	bne LoadMenuDecreaseOptionNoEnd
-	
-	plp
-	ply
-	rts
-	
-LoadMenuDecreaseOptionNoEnd:
-
-	
-	ldy.w #$0000
-;	lda.b [MenuRowsThreeByteOptionPointerLo],y	;get byte, increase it and compare if its greater than the maximum value
-
-	lda.b [MenuRowsThreeBytePointerLo],y
-	cmp.b #1
-	bne LoadMenuDecNoByte				;only check for b if we're processing a byte-option
-
-	lda.w JoyPortBufferTrigger&$ffff+1
-	bpl LoadMenuDecNoByte
-
-	sec
-	lda.b [MenuRowsThreeByteOptionPointerLo],y	;save back changed value
-	sbc.b #$f					;add a whole nibble if b is pressed
-	sta.b [MenuRowsThreeByteOptionPointerLo],y
-
-LoadMenuDecNoByte:	
-
-	lda.b [MenuRowsThreeByteOptionPointerLo],y	;get byte, increase it and compare if its greater than the maximum value
-	dec a
-	
-	cmp.b #$ff
-	beq LoadMenuDecreaseOptionOverflow
-	ldy.w #$0002
-	cmp.b [MenuRowsThreeBytePointerLo],y
-	bcs LoadMenuDecreaseOptionNoOverflow
-LoadMenuDecreaseOptionOverflow:	
-	ldy.w #$0003
-	lda.b [MenuRowsThreeBytePointerLo],y	;get minimum value if wrap around
-				
-LoadMenuDecreaseOptionNoOverflow:
-	ldy.w #$0000
-	sta.b [MenuRowsThreeByteOptionPointerLo],y	;save back changed value
-	lda.b #$01
-	sta.b LoadMenuPalUnselSel		;redraw current option
-	jsr LoadMenuDrawDescString
-	jsr LoadMenuDrawOptionValue
-	plp
-	ply
-	rts
-
-
-LoadMenuExecuteSubroutine:
-	pha
-	phy
-	phx
-	php
-	phd
-	phb
-	rep #$31
-	sep #$20
-	lda.b #$7e
-	pha
-	plb
-	
-	ldy.w #0007
-	lda.b [MenuRowsThreeBytePointerLo],y	;get number of subroutine to execute
-	clc
-	asl a
-	tax
-	jsr (MenuSubroutineLUT,x)
-	
-	
-	plb
-	pld
-	plp
-	plx
-	ply
-	pla
-	rts
-	
-	
-
-	
-	
-MenuDataTypeVoid:
-MenuDataType0:
-	rts					;no action if theres no string to draw
-
-
-MenuDataType1:
-	phx
-	phy
-	php
-	rep #$31
-	lda.b LoadMenuInitialOptionOffset	;get relative offset of option
-	and.w #$00ff
-	adc.b LoadMenuStringPosLo		;add offset of current row
-	sta.w LoadMenuStringBuffer&$ffff+1		;store in string position
-	ldy.w #$0004
-	lda.b [MenuRowsThreeBytePointerLo],y	;get pointer to byte
-	sta.w LoadMenuStringBuffer&$ffff+6
-	sep #$20
-	iny
-	iny
-	lda.b [MenuRowsThreeBytePointerLo],y	;get bank pointer to byte
-	sta.w LoadMenuStringBuffer&$ffff+8
-	lda.b #$05				;write "draw byte" command"
-	sta.w LoadMenuStringBuffer&$ffff+5
-	ldx.w #2			;print to screen
-	jsr LoadTextString
-	plp
-	ply
-	plx
-	rts
-
-MenuDataType2:
-	phx
-	phy
-	php
-	rep #$31
-	lda.b LoadMenuInitialOptionOffset	;get relative offset of option
-	and.w #$00ff
-	adc.b LoadMenuStringPosLo		;add offset of current row
-	sta.w LoadMenuStringBuffer&$ffff+1		;store in string position
-	ldy.w #$0004
-	lda.b [MenuRowsThreeBytePointerLo],y	;get pointer to byte
-	sta.w LoadMenuStringBuffer&$ffff+6
-	sep #$20
-	iny
-	iny
-	lda.b [MenuRowsThreeBytePointerLo],y	;get bank pointer to byte
-	sta.w LoadMenuStringBuffer&$ffff+8
-	lda.b #$06				;write "draw byte" command"
-	sta.w LoadMenuStringBuffer&$ffff+5
-	ldx.w #2			;print to screen
-	jsr LoadTextString
-	plp
-	ply
-	plx
-	rts
-
-MenuDataType3:
-	phx
-	phy
-	php
-	rep #$31
-	lda.b LoadMenuInitialOptionOffset	;get relative offset of option
-	and.w #$00ff
-	adc.b LoadMenuStringPosLo		;add offset of current row
-	sta.w LoadMenuStringBuffer&$ffff+1		;store in string position
-
-	lda.w #$0000				;clear a
-	sep #$20
-	ldy.w #$0001
-	lda.b [MenuRowsThreeBytePointerLo],y	;get bitmask
-	sta.w LoadMenuStringBuffer&$ffff+6		;just a temporary buffer
-
-	ldy.w #$0000
-	lda.b [MenuRowsThreeByteOptionPointerLo],y
-	and.w LoadMenuStringBuffer&$ffff+6		;check which string to choose
-	rep #$31					;if string1, a=0
-	and.w #$ff
-;	beq MenuDataType3String1
-	
-;	lda.b #$02				;load textstring 2, two byte pointer
-;MenuDataType3String1:
-	asl a					;2byte pointer
-
-	adc.w #0012				;add until we're at pointer for string 1 or 2
-	tay
-	lda.b [MenuRowsThreeBytePointerLo],y	;get relative string pointer
-	clc
-	adc.b MenuFileThreeBytePointerLo		;add file offset to get real pointer
-	sta.w LoadMenuStringBuffer&$ffff+6
-	sep #$20
-	lda.b MenuFileThreeBytePointerBank
-	sta.w LoadMenuStringBuffer&$ffff+8
-
-	lda.b #$04				;write "draw string from adress" command"
-	sta.w LoadMenuStringBuffer&$ffff+5
-	ldx.w #2			;print to screen
-	jsr LoadTextString
-	plp
-	ply
-	plx
-	rts
-
-
-
-LoadMenuInitialOptionDrawDataTypeJumpTable:
-	.dw MenuDataType0
-	.dw MenuDataType1
-	.dw MenuDataType2
-	.dw MenuDataType3
-	.dw MenuDataTypeVoid
-	.dw MenuDataTypeVoid
-	.dw MenuDataTypeVoid
-	.dw MenuDataTypeVoid
-
-
-LoadMenuDrawDescString:
-	phy
-	phx
-	php
-	rep #$31				;16bit and carry clear
-	lda.w #$0000
-	tax
-
-LoadMenuDrawDescStringClearBufferLoop:	
-	sta.w LoadMenuStringBuffer&$ffff,x
-	inx
-	inx
-	cpx.w #$0008				;clear 16 bytes of string buffer
-	bcc LoadMenuDrawDescStringClearBufferLoop
-	
-	
-	lda.b LoadMenuCurrentRow
-	and.w #$001f
-	tax
-	lda.w #$0000
-	
-LoadMenuDrawDescStringVertPosLoop:	
-	cpx.w #$0000
-	beq LoadMenuDrawDescStringVertPosLoopExit
-
-	clc
-	adc.b LoadMenuVerticalSpacing
-	dex
-	bra LoadMenuDrawDescStringVertPosLoop
-LoadMenuDrawDescStringVertPosLoopExit:
-	clc
-	adc.b LoadMenuInitialOffset	;add offset of whole menu
-	sta.b LoadMenuStringPosLo	;store in initial offset of current row
-	sta.w LoadMenuStringBuffer&$ffff+1
-
-	lda.b LoadMenuPalUnselSel
-	and.b #$0001			;only get lowest bit to check if we should draw highlighted or not
-	clc
-	adc.w #0008			;get palette number 10=unselected, 11=selected
-	tay
-	sep #$20
-	lda.b [MenuRowsThreeBytePointerLo],y
-	sta.w LoadMenuStringBuffer&$ffff+4
-	lda.b #$04			;script command "set string adress"
-	sta.w LoadMenuStringBuffer&$ffff+5
-
-	inc.w LoadMenuStringBuffer&$ffff	;script command "set position" for description text
-	lda.b #$07			;script command "set palette"
-	sta.w LoadMenuStringBuffer&$ffff+3
-	
-	rep #$31
-	ldy.w #0010			;get string offset
-	lda.b [MenuRowsThreeBytePointerLo],y
-	adc.b MenuFileThreeBytePointerLo	;add file offset to get real pointer
-	sta.w LoadMenuStringBuffer&$ffff+6
-	sep #$20
-	lda.b MenuFileThreeBytePointerBank
-	sta.w LoadMenuStringBuffer&$ffff+8
-
-	ldx.w #2			;print to screen
-	jsr LoadTextString
-
-	plp
-	plx
-	ply
-	rts
-
-LoadMenuSetupRowPointer:
-	phy
-	php
-	rep #$31				;16bit and carry clear
-	lda.b LoadMenuCurrentRow
-	and.w #$001f
-	asl a
-	adc.w #$0005				;add offset of relative pointertable in menu file
-	tay
-	lda.b [MenuFileThreeBytePointerLo],y
-	adc.b MenuFileThreeBytePointerLo		;add file offset to get real pointer
-	sta.b MenuRowsThreeBytePointerLo
-	sep #$20
-	lda.b MenuFileThreeBytePointerBank
-	sta.b MenuRowsThreeBytePointerBank
-
-	ldy.w #$0006				;get option byte bank pointer
-	lda.b [MenuRowsThreeBytePointerLo],y
-	sta.b MenuRowsThreeByteOptionPointerBank
-
-	rep #$30	
-	ldy.w #$0004				;get option byte pointer
-	lda.b [MenuRowsThreeBytePointerLo],y
-	sta.b MenuRowsThreeByteOptionPointerLo
-	sep #$20
-/*
-	ldy.w #$0009				;get options subroutine byte bank pointer
-	lda.b [MenuRowsThreeBytePointerLo],y
-	sta.b MenuRowsThreeByteCodePointerBank
-
-	rep #$30	
-	ldy.w #$0007				;get options subroutine byte pointer
-	lda.b [MenuRowsThreeBytePointerLo],y
-	sta.b MenuRowsThreeByteCodePointerLo
-	sep #$20
-*/
-	
-	plp
-	ply
-	rts
-	
-LoadMenuDrawOptionValue:
-	phy
-	phx
-	php
-	rep #$31
-	ldy.w #0000			;get option data type
-	tya
-	sep #$20
-	lda.b [MenuRowsThreeBytePointerLo],y
-	and.b #$07			;maximum number of types=7
-	asl
-	tax
-	jsr (LoadMenuInitialOptionDrawDataTypeJumpTable,x)
-	plp
-	plx
-	ply
-	rts
-	

+ 0 - 530
snes/loader/routines/miscdata.asm

@@ -1,530 +0,0 @@
-	
-
-
-
-
-
-
-
-
-.Section "Misc Data 1" superfree
-;mosaic and hdma count value table used when fading bg1&2 in/out:
-Bg12FadeLUT:
-;0
-	.db 2				;window count value (1-99)
-	.db %00000011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-;1
-	.db 3				;window count value (1-99)
-	.db %00010011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;2
-	.db 4				;window count value (1-99)
-	.db %00100011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;3
-	.db 6				;window count value (1-99)
-	.db %00110011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;4
-	.db 8				;window count value (1-99)
-	.db %01000011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;5
-	.db 11				;window count value (1-99)
-	.db %01010011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;6
-	.db 15				;window count value (1-99)
-	.db %01100011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;7
-	.db 18				;window count value (1-99)
-	.db %01110011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;8
-	.db 23				;window count value (1-99)
-	.db %10000011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;9
-	.db 27				;window count value (1-99)
-	.db %10010011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;10
-	.db 35				;window count value (1-99)
-	.db %10100011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;11
-	.db 45				;window count value (1-99)
-	.db %10110011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;12
-	.db 57				;window count value (1-99)
-	.db %11000011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;13
-	.db 70				;window count value (1-99)
-	.db %11010011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111111			;and value with mainscreen settings
-	.db 0				;void
-
-;14
-	.db 88				;window count value (1-99)
-	.db %11100011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111100			;and value with mainscreen settings
-	.db 0				;void
-
-;15
-	.db 99				;window count value (1-99)
-	.db %11110011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111100			;and value with mainscreen settings
-	.db 0				;void
-
-;16
-	.db 99				;window count value (1-99)
-	.db %11110011			;mosaic value (xxxx4321, x is mosaic size)
-	.db %11111100			;and value with mainscreen settings
-	.db 0				;void
-.ends
-
-.Section "MemoryViewLUT" superfree
-MemoryViewerLetterLUT:
-	.db $f0
-	.db $f1
-	.db $f2	
-	.db $f3	
-	.db $f4	
-	.db $f5	
-	.db $f6	
-	.db $f7	
-	.db $f8	
-	.db $f9	
-	.db $b0	
-	.db $b1	
-	.db $b2	
-	.db $b3	
-	.db $b4	
-	.db $b5
-.ends	
-
-
-.Section "ScreenFocusLUT" superfree
-FocusScreenSplineLut:
-	.dw FocusScreenSpline0
-	.dw FocusScreenSpline1
-	.dw FocusScreenSpline2
-	.dw FocusScreenSpline3
-	.dw FocusScreenSpline4
-	.dw FocusScreenSpline5
-	.dw FocusScreenSpline6
-	.dw FocusScreenSpline7			;linear ramp
-
-FocusScreenSpline0:
-FocusScreenSpline1:
-FocusScreenSpline2:
-FocusScreenSpline3:
-FocusScreenSpline4:
-FocusScreenSpline5:
-FocusScreenSpline6:
-FocusScreenSpline7:
-	.db $60
-	.db $60
-	.db $60
-	.db $60
-	.db $50
-	.db $50
-	.db $50
-	.db $50
-	.db $40
-	.db $40
-	.db $40
-	.db $40
-	.db $30
-	.db $30
-	.db $30
-	.db $30
-	.db $20
-	.db $20
-	.db $20
-	.db $20
-	.db $10
-	.db $10
-	.db $10
-	.db $10
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 1
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 2
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 3
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 4
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 5
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 6
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-	.db 7
-.ends
-
-.Section "blanktile" superfree
-BlankTile:
-	.incbin "data/blanktile.pic"
-.ends	
-
-/*
-this is the table that defines the transfer length and number for the different sprites.
-bit0-3 of adress: obj size designation
-bit4 of adress: objs own size flag
-1st byte of data: transfer length
-2nd byte of data: transfer number
-
-xsize:	ysize:	number of lines to upload:	number of bytes to transfer per line:
-8	8	1				32
-16	16	2				64
-32	32	4				128
-64	64	8				256
-16	32	4				64
-32	64	8				128
-*/
-.Section "ObjsizeLUT" superfree
-ObjSizeLUT:
-
-;8x8
-	.db 31		;transfer length
-	.db 1		;number of transfers
-	.db 1		;transfer type
-;8x8
-	.db 31
-	.db 1
-	.db 1
-;8x8
-	.db 31
-	.db 1
-	.db 1
-;16x16
-	.db 63
-	.db 2
-	.db 3
-;16x16
-	.db 63
-	.db 2
-	.db 3
-;32x32
-	.db 127
-	.db 4
-	.db 4
-;16x32
-	.db 63
-	.db 4
-	.db 0		;not supported atm
-;16x32
-	.db 63
-	.db 4
-	.db 0		;not supported atm	
-;size flag=1
-;16x16
-	.db 63
-	.db 2
-	.db 3
-;32x32
-	.db 127
-	.db 4
-	.db 4
-;64x64
-	.db 255
-	.db 8
-	.db 5
-;32x32
-	.db 127
-	.db 4
-	.db 4
-;64x64
-	.db 255
-	.db 8
-	.db 5
-;64x64
-	.db 255
-	.db 8
-	.db 5
-;32x64
-	.db 127
-	.db 8
-	.db 0		;not supported atm	
-;32x32
-	.db 127
-	.db 4
-	.db 4
-.ends
-
-
-
-.Section "Fonts" superfree
-Bg38x8FontLUT:
-	.dw Font0
-	.dw Font0End-Font0
-	.dw Font1
-	.dw Font1End-Font1
-	.dw Font2
-	.dw Font2End-Font2
-	.dw Font3
-	.dw Font3End-Font3
-
-Font0:
-	.INCBIN "data/font/font1.pic"
-Font0End:	
-Font1:
-;	.INCBIN "data/font2.pic"
-Font1End:	
-Font2:
-;	.INCBIN "data/font2.pic"
-Font2End:	
-Font3:
-;	.INCBIN "data/font2.pic"
-Font3End:	
-
-
-BG38x8FontPalette:
-	.INCBIN "data/font/font1pal.clr" READ 32
-BG38x8FontPaletteEnd:
-
-.ends
-
-.Section "ascii tables" superfree
-ASCIITable:
-	.incbin "data/font/asciitablejap.tbl"
-	
-ASCIITable8x16:
-;	.incbin "data/font/asciitable8x16.tbl"
-.ends
-
-
-
-
-
-
-	
-	
-.Section "Audio Player" superfree
-PtplayerSpcCode:
-	.dw (PtplayerSpcCodeEnd-PtplayerSpcCode-2)
-	
-	.incbin "data/apu/apucode.bin"			
-	
-PtplayerSpcCodeEnd:
-	.dw $0000		;termination code
-	.dw $0000
-	.incbin "data/apu/apucode.bin" READ 2		;spc start adress
-.ends	
-
-
-
-
-	
-
-.section "general tilesets" superfree
-GeneralTilesetsLUT:
-		.dw GeneralTileset0
-		.db (:GeneralTileset0+BaseAdress>>16)
-		.dw (GeneralTileset0End-GeneralTileset0)
-		.dw GeneralTileset1
-		.db (:GeneralTileset1+BaseAdress>>16)
-		.dw (GeneralTileset1End-GeneralTileset1)
-		.dw GeneralTileset2
-		.db (:GeneralTileset2+BaseAdress>>16)
-		.dw (GeneralTileset2End-GeneralTileset2)
-
-.ends
-
-.section "general tileset 2" superfree
-GeneralTileset0:
-GeneralTileset0End:
-GeneralTileset1:
-GeneralTileset1End:
-GeneralTileset2:
-	.incbin "data/blanktile.pic"
-GeneralTileset2End:
-.ends
-
-
-
-
-
-.section "hex2dec lut" superfree
-VwfHex2DecLUT:
-	.db    $0, $0, $0, $0, $0, $1,  $0, $0, $0, $0, $0, $2,  $0, $0, $0, $0, $0, $4,  $0, $0, $0, $0, $0, $8
- 	.db    $0, $0, $0, $0, $0,$16,  $0, $0, $0, $0, $0,$32,  $0, $0, $0, $0, $0,$64,  $0, $0, $0, $0, $1,$28
-  .db    $0, $0, $0, $0, $2,$56,  $0, $0, $0, $0, $5,$12,  $0, $0, $0, $0,$10,$24,  $0, $0, $0, $0,$20,$48
-  .db    $0, $0, $0, $0,$40,$96,  $0, $0, $0, $0,$81,$92,  $0, $0, $0, $1,$63,$84,  $0, $0, $0, $3,$27,$68
-
-	.db    $0, $0, $0, $6,$55,$36,  $0, $0, $0,$13,$10,$72,  $0, $0, $0,$26,$21,$44,  $0, $0, $0,$52,$42,$88
- 	.db    $0, $0, $1,$04,$85,$76,  $0, $0, $2,$09,$71,$52,  $0, $0, $4,$19,$43,$04,  $0, $0, $8,$38,$86,$08
-  .db    $0, $0,$16,$77,$72,$16,  $0, $0,$33,$55,$44,$32,  $0, $0,$67,$10,$88,$64,  $0, $1,$34,$21,$77,$28
-  .db    $0, $2,$68,$43,$54,$56,  $0, $5,$36,$87,$09,$12,  $0,$10,$73,$74,$18,$24,  $0,$21,$47,$48,$36,$48
-
-.ends  
-
-
-
-
-
-
-.Section "playerselectscroll" superfree	
-PlayerSelectScrollCounterTable:
-	.dw 2
-	.dw 2
-	.dw 1
-	.dw 1
-	.dw 0						;wait for "hit any button"
-	.dw 0
-	.dw 0
-	.dw 0
-	.dw 0
-	.dw 0
-	.dw 1
-	.dw 1
-	.dw 2
-	.dw 2
-	.dw 2
-	.dw 2
-	.dw 2
-		
-	.dw 2
-	.dw 2
-	.dw 1
-	.dw 1	
-	.dw 0						;wait for "waiting for challengers"
-	.dw 0
-	.dw 0
-	.dw 0
-	.dw 0
-	.dw 0
-	.dw 1
-	.dw 1
-	.dw 2
-	.dw 2
-	.dw 2
-.ends	

+ 0 - 1045
snes/loader/routines/oamanimationlists.asm

@@ -1,1045 +0,0 @@
-.Section "oam anilists" superfree
-;relative pointers to object animation files
-ObjectAnimationLUT:
-	.dw (ObjAniList000-ObjectAnimationLUT)
-	.dw (ObjAniList001-ObjectAnimationLUT)
-	.dw (ObjAniList002-ObjectAnimationLUT)
-	.dw (ObjAniList003-ObjectAnimationLUT)
-	.dw (ObjAniList004-ObjectAnimationLUT)
-	.dw (ObjAniList005-ObjectAnimationLUT)
-	.dw (ObjAniList006-ObjectAnimationLUT)
-	.dw (ObjAniList007-ObjectAnimationLUT)
-	.dw (ObjAniList008-ObjectAnimationLUT)
-	.dw (ObjAniList009-ObjectAnimationLUT)
-	.dw (ObjAniList010-ObjectAnimationLUT)
-	.dw (ObjAniList011-ObjectAnimationLUT)
-	.dw (ObjAniList012-ObjectAnimationLUT)		
-	.dw (ObjAniList013-ObjectAnimationLUT)
-	.dw (ObjAniList014-ObjectAnimationLUT)
-	.dw (ObjAniList015-ObjectAnimationLUT)
-	.dw (ObjAniList016-ObjectAnimationLUT)
-	.dw (ObjAniList017-ObjectAnimationLUT)
-	.dw (ObjAniList018-ObjectAnimationLUT)
-	.dw (ObjAniList019-ObjectAnimationLUT)
-	.dw (ObjAniList020-ObjectAnimationLUT)
-	.dw (ObjAniList021-ObjectAnimationLUT)
-	.dw (ObjAniList022-ObjectAnimationLUT)
-	.dw (ObjAniList023-ObjectAnimationLUT)
-	.dw (ObjAniList024-ObjectAnimationLUT)
-	.dw (ObjAniList025-ObjectAnimationLUT)
-	.dw (ObjAniList026-ObjectAnimationLUT)
-	.dw (ObjAniList027-ObjectAnimationLUT)
-	.dw (ObjAniList028-ObjectAnimationLUT)
-	.dw (ObjAniList029-ObjectAnimationLUT)
-	.dw (ObjAniList030-ObjectAnimationLUT)
-	.dw (ObjAniList031-ObjectAnimationLUT)
-	.dw (ObjAniList032-ObjectAnimationLUT)
-	.dw (ObjAniList033-ObjectAnimationLUT)
-	
-	
-ObjAniList000:
-;testsprite walk downwards:
-;	.dw $0100			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	
-	.dw $0183			;next animation frame
-	.dw $1002			;and scroll right a pixel
-	
-	
-	.dw $000d			;nop
-	.dw $0183			;next animation frame
-	.dw $1002			;and scroll right a pixel
-
-	
-
-	.dw $000d			;nop
-	.dw $0183			;next animation frame
-	.dw $1002			;and scroll right a pixel
-
-	.dw $000d			;nop
-	.dw $0183			;next animation frame
-	.dw $1002			;and scroll right a pixel
-
-	.dw $000d			;nop
-	.dw $0183			;next animation frame
-	.dw $1002			;and scroll right a pixel
-
-	
-	.dw $000d			;nop
-	.dw $0184			;goto tileset frame 1
-	.dw $7685			;set palette and config
-	.dw $1002			;and scroll right a pixel
-
-	.dw $000d			;nop
-	.dw $0183			;next animation frame
-	.dw $1002			;and scroll right a pixel
-	
-	.dw $000d			;nop
-	.dw $0183			;next animation frame
-	.dw $1002			;and scroll right a pixel
-
-	.dw $000d			;nop
-	.dw $0183			;next animation frame
-	.dw $1002			;and scroll right a pixel
-
-	.dw $000d			;nop
-	.dw $0183			;next animation frame
-	.dw $1002			;and scroll right a pixel
-
-
-	.dw $000d			;nop
-	.dw $0184			;goto tileset frame 1
-	.dw $3685			;set palette and config
-	
-;	.dw $0001
-	.dw $0606			;goto frame 6 in this animation
-
-	
-ObjAniList001:
-;main chara top body walking down
-	.dw $0580			;create object 5
-	.dw $0287			;goto command list 3
-
-ObjAniList002:
-;male walking
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-;walking animation
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-
-	.dw $0284			;add 2 tileset frames
-
-	.dw $0406			;loop walking animation
-
-	
-ObjAniList003:
-;male punching
-	.dw $0203			;add 2 tileset frames
-	.dw $020a			;set subroutine to void	
-	.dw $0103			;add 2 tileset frames
-	.dw $0103			;add 2 tileset frames
-	
-	.dw $010d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $ff03			;add 2 tileset frames
-
-	.dw $0d0a			;reset subroutine to normal
-	.dw $000e			;infinite waitloop
-
-ObjAniList004:
-;male standing still top
-	.dw $0004			;goto tileset frame 1
-	.dw $000e			;goto animation frame 0(endless loop)
-
-ObjAniList005:
-;male falling
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-;standing up, not moving anymore:
-	.dw $020a			;set subroutine to void	
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-
-	.dw $000d			;nop
-	.dw $000d			;nop
-	
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $0e0a			;reset subroutine to normal again, turn player around
-	.dw $000e			;infinite waitloop
-
-
-ObjAniList006:
-;main chara top body walking down
-	.dw $0780			;create object 7
-	.dw $0487			;goto command list 4
-
-ObjAniList007:
-;male fierce punch
-	.dw $0103			;add 2 tileset frames
-	.dw $000d
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-
-
-
-	.dw $000c			;play soundeffect
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $050a			;set subroutine to fierce punch
-	.dw $0103			;add 2 tileset frames
-	.dw $020a			;set subroutine to void
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-
-
-	.dw $0d0a			;reset subroutine to normal again
-	.dw $000e			;infinite waitloop
-
-ObjAniList008:
-;male falling far (fierce punch)
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-
-	
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-
-	
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-
-	
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-		
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	
-
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-;standing up, not moving anymore:
-	.dw $020a			;set subroutine to void	
-	
-	
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-
-	.dw $000d			;nop
-	.dw $000d			;nop
-	
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $0e0a			;reset subroutine to normal again, turn player around
-	.dw $000e			;infinite waitloop
-	
-
-ObjAniList009:
-;male death/fail continuous
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-
-;animation loops here
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $100d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $0b84			;reset tileset frame
-	.dw $1606			;loop back to shake head sequence
-
-
-	
-
-ObjAniList010:
-;male falling far (death)
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-
-	
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-
-	
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-
-	
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-		
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	
-
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-	.dw $000d			;nop
-;not moving anymore:
-	.dw $0a0a			;set subroutine to dead	
-	.dw $000e			;infinite waitloop
-
-ObjAniList011:
-;male sitting in menu
-
-	.dw $0103			;add 2 tileset frames
-	.dw $050d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $050d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $050d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $050d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $050d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $050d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $200d			;nop
-
-	.dw $0004			;reset tileset frame
-	.dw $050d			;nop	
-
-	.dw $050d			;nop	
-	.dw $050d			;nop	
-	.dw $0006			;repeat animation
-
-
-
-
-ObjAniList012:
-;male standing up in menu
-	.dw $0b04			;add 2 tileset frames
-
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames	
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $010d			;nop
-
-	.dw $0103			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-
-
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $050d			;nop
-	.dw $0103			;add 2 tileset frames	
-	.dw $050d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $050d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-
-	.dw $070a			;set subroutine to menu running
-	.dw $000d			;nop
-	.dw $0006			;repeat animation
-	
-
-
-
-ObjAniList013:
-;male spasm for revival
-	.dw $028a			;set subroutine to void (so player has to wait and autofire doesn't help much)
-	.dw $0504			;set frame 6
-	.dw $060d			;nop
-
-	.dw $0103			;add 2 tileset frames
-	.dw $060d			;nop
-
-	
-	.dw $0103			;add 2 tileset frames
-	.dw $080d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0a0a			;set subroutine to dead again
-	.dw $000e			;infinite waitloop
-
-;male winner cheering:
-ObjAniList014:
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-
-;animation loops here:
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-
-	.dw $030d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $1206			;loop animation
-
-ObjAniList015:
-;main chara top body battle steady still
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-
-	.dw $fe03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $fe03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $fe03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $fe03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $fe03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $fe03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $fe03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $fe03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $fe03			;substract 2 tileset frames
-	.dw $000d			;nop	
-
-
-	.dw $0006			;loop walking animation
-
-ObjAniList016:
-;small main chara top body battle steady still
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-
-	.dw $ff03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $ff03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $ff03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $ff03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $ff03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $ff03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $ff03			;substract 2 tileset frames
-	.dw $000d			;nop	
-	.dw $ff03			;substract 2 tileset frames
-	.dw $000d			;nop	
-
-
-	.dw $0006			;loop walking animation
-
-;explosion init
-ObjAniList017:
-
-
-;explosion play
-ObjAniList018:
-	.dw $010d
-	.dw $0403
-	.dw $010d
-	.dw $0403
-	.dw $010d
-	.dw $0403
-	.dw $010d
-	.dw $0403
-	.dw $010d
-	.dw $0403
-	.dw $010d
-	.dw $0403	
-;	.dw $050f
-	.dw $010d
-	.dw $0001			;delete
-
-;gra g
-ObjAniList019:
-	.dw $050d
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-
-
-
-
-	.dw $1606			;loop walking animation
-	
-	
-ObjAniList020:
-;gra gra
-	.dw $000d
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $040d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $030d			;nop
-	.dw $1d06			;loop walking animation
-	
-	
-ObjAniList021:
-;male being stunned
-	.dw $0103			;add 2 tileset frames
-	.dw $0103			;add 2 tileset frames
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-
-
-	.dw $0d0a			;reset subroutine to normal
-	.dw $000e			;infinite waitloop
-	
-ObjAniList022:
-;male blocking
-	.dw $0103			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0103			;add 2 tileset frames
-	.dw $0f0a			;set subroutine to block
-	.dw $0103			;add 2 tileset frames
-	.dw $0a0d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $010d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $020d			;nop
-	.dw $ff03			;add 2 tileset frames
-	.dw $0d0a			;reset subroutine to normal
-	
-	.dw $000e			;infinite waitloop		
-	
-	
-ObjAniList023:
-;male block success, pushing back
-	.dw $0203			;add 2 tileset frames
-	.dw $000d			;nop
-	.dw $0203			;add 2 tileset frames
-	.dw $0103			;add 2 tileset frames
-	
-	.dw $0f0a			;set subroutine to block
-	.dw $ff03			;sub 2 tileset frames
-	.dw $000d			;nop
-	.dw $ff03			;sub 2 tileset frames
-	.dw $000d			;nop
-	.dw $ff03			;sub 2 tileset frames
-	.dw $000d			;nop
-	.dw $ff03			;sub 2 tileset frames
-	.dw $000d			;nop
-
-	.dw $ff03			;sub 2 tileset frames
-	.dw $000d			;nop
-	.dw $0d0a			;reset subroutine to normal
-	
-	.dw $000e			;infinite waitloop		
-	
-ObjAniList024:
-	.dw $070d			;nop
-	.dw $0102			;move down
-	.dw $070d			;nop
-	.dw $0102			;move down	
-	.dw $030d			;nop
-	.dw $0102			;move down	
-	.dw $010d			;nop
-	.dw $0102			;move down	
-	.dw $000d			;nop
-	.dw $0102			;move down	
-	.dw $000d			;nop
-	.dw $0102			;move down	
-	.dw $0102			;move down	
-	.dw $0102			;move down
-	.dw $0102			;move down
-
-	
-
-
-	
-	.dw $0102			;move down
-	.dw $000d			;nop	
-	.dw $0102			;move down
-	.dw $000d			;nop
-	.dw $0102			;move down
-	.dw $010d			;nop		
-	.dw $0102			;move down
-	.dw $030d			;nop	
-	.dw $0102			;move down
-	.dw $070d			;nop	
-	.dw $0102			;move down	
-
-	.dw $070d			;nop
-	
-	.dw $0902			;move down
-	.dw $070d			;nop
-	.dw $0902			;move down	
-	.dw $030d			;nop
-	.dw $0902			;move down	
-	.dw $010d			;nop
-	.dw $0902			;move down	
-	.dw $000d			;nop
-	.dw $0902			;move down	
-	.dw $000d			;nop
-	.dw $0902			;move down	
-	.dw $0902			;move down	
-	.dw $0902			;move down
-	.dw $0902			;move down
-
-
-	
-
-
-	
-	.dw $0902			;move down
-	.dw $000d			;nop	
-	.dw $0902			;move down
-	.dw $000d			;nop
-	.dw $0902			;move down
-	.dw $010d			;nop		
-	.dw $0902			;move down
-	.dw $030d			;nop	
-	.dw $0902			;move down
-	.dw $070d			;nop	
-	.dw $0902			;move down	
-	
-
-	.dw $0006			;reset
-	
-;particle
-ObjAniList025:
-	.dw $0110			;vector speed
-	.dw $b411			;vector dir
-	.dw $020d			;nop
-	.dw $c310			;vector speed
-	.dw $040d			;nop
-	.dw $e411			;vector dir	
-	.dw $080d			;nop
-	.dw $c110			;vector speed
-
-	.dw $0b0d			;nop
-	.dw $3411
-	.dw $c310			;vector speed
-	.dw $e411			;vector dir
-	
-	.dw $0b0d			;nop
-	
-	.dw $0001			;del
-
-;particle
-ObjAniList026:
-
-	.dw $db11			;vector dir
-	.dw $020d			;nop
-	.dw $df10			;vector speed
-	.dw $040d			;nop
-	.dw $e011			;vector dir	
-	.dw $080d			;nop
-	.dw $f010			;vector speed
-
-	.dw $0b0d			;nop
-	.dw $1911
-	.dw $d810			;vector speed
-	.dw $dc11			;vector dir
-	
-	.dw $0b0d			;nop
-	
-	.dw $0001			;del	
-	
-	
-;particle
-ObjAniList027:
-
-	.dw $8411			;vector dir	
-	.dw $080d			;nop
-	.dw $c810			;vector speed
-	.dw $080d			;nop
-	.dw $c310			;vector speed
-
-	.dw $180d			;nop
-	
-	.dw $0001			;del
-
-
-;particle
-ObjAniList028:
-
-	.dw $9711			;vector dir	
-	.dw $080d			;nop
-	.dw $c810			;vector speed
-	.dw $080d			;nop
-	.dw $c310			;vector speed
-
-	.dw $120d			;nop
-	
-	.dw $0001			;del
-	
-
-;particle
-ObjAniList029:
-
-	.dw $b811			;vector dir
-	.dw $020d			;nop
-	.dw $df10			;vector speed
-	.dw $020d			;nop
-	.dw $e011			;vector dir	
-	.dw $080d			;nop
-	.dw $f010			;vector speed
-
-	.dw $080d			;nop
-	.dw $3911
-	.dw $d710			;vector speed
-	.dw $e211			;vector dir
-	
-	.dw $060d			;nop
-	
-	.dw $0001			;del
-;particle
-ObjAniList030:
-
-	.dw $c611			;vector dir
-	.dw $050d			;nop
-	.dw $d910			;vector speed
-	.dw $e011			;vector dir	
-	.dw $050d			;nop
-
-	.dw $080d			;nop
-;	.dw $d810			;vector speed
-
-	.dw $050d			;nop
-	.dw $0211			;vector dir
-	.dw $c610			;vector speed
-	.dw $d711			;vector dir
-	
-	.dw $240d			;nop
-	
-	.dw $0001			;del
-	
-;particle
-ObjAniList031:
-
-	.dw $9911			;vector dir
-	.dw $050d			;nop
-	.dw $df10			;vector speed
-	.dw $dd11			;vector dir	
-	.dw $080d			;nop
-	.dw $d510			;vector speed
-	.dw $240d			;nop
-	
-	.dw $0001			;del
-;particle
-ObjAniList032:
-
-	.dw $f411			;vector dir
-	.dw $060d			;nop
-	.dw $df10			;vector speed
-	.dw $f011			;vector dir	
-	.dw $040d			;nop
-	.dw $cf10			;vector speed
-	.dw $e911			;vector dir	
-	.dw $080d			;nop
-	
-	.dw $c310			;vector speed
-	.dw $080d			;nop
-	.dw $0001			;del
-;particle
-ObjAniList033:
-
-	.dw $ff11			;vector dir
-	.dw $030d			;nop
-	.dw $df10			;vector speed
-	.dw $fc11			;vector dir	
-	.dw $020d			;nop
-	.dw $cf10			;vector speed
-	.dw $fb11			;vector dir	
-	.dw $050d			;nop
-	
-	.dw $c310			;vector speed
-	.dw $080d			;nop
-	.dw $0001			;del
-	
-.ends

+ 0 - 3092
snes/loader/routines/oammanager.asm

@@ -1,3092 +0,0 @@
-/*
-this is the sprite/oam routine file.
-
-direct sprite features:
--setup sprite variables
--create and upload spritelist-buffer to oam-ram
--upload sprite palettes
-
-object manager features:
--create and process object list
--create objects, each with own memory space
--delete objects
--routines for:
-	-cycling through animations
-	-moving objects along preset paths
-	
-areas needed:
-OAMBuffer		ds 200
-oam memory format:
-Byte 1    xxxxxxxx    x: X coordinate
-Byte 2    yyyyyyyy    y: Y coordinate
-Byte 3    cccccccc    c: starting character (tile) number    p: palette number
-Byte 4    vhoopppc    v: vertical flip   h: horizontal flip  o: priority bits
-          Note: the 'c' in byte 4 is the MOST significant bit in the 9-bit char #.
-
-00110000
-
-OAMPriorityBuffer	ds 20
-oam priority format:
-2bits per sprite, 4 sprites per byte
-bit0 = size toggle
-bit1 = x coordinate msb
-
-ObjectList		ds $400
-
-Maximum number of objects: 64
-Object Format: 32bytes per object
-	.db %11101010		;0 object type designation
-				;bit0=X position sign of sprite(usually 0)
-				;bit1=Object size flag
-				;bit2=collidable
-				;bit3=subroutine? if set, this object has its own subroutine that must be executed every frame
-				;bit4=animate? if set, this object is animated(a special table for each object specifies the exact animation with commands for tileloading, waiting, animation loop etc)
-				;bit5=bg-bound? if set, this object must move in accordance with background layer 0
-				;bit6=object active? if set, this object is active and needs to be drawn. if clear, this sprite doesnt need to be drawn, but must be processed, anyway
-				;bit7=object present? if set, this slot has an object. if clear, its considered empty and can be overwritten
-	.db %00000000		;1 object type designation 2
-				;bit7=pseudo 3d sprite that needs to be moved according to z-value when background moves
-				;bit6=don't upload tiles for this sprite. useful for stuff like particles and such where lots of sprites share the same tiles.
-	.db 6			;2 number of subroutine. executed if bit6 of object type is set
-	.db 14			;3 tileset to use
-	.db 9			;4 current "frame" of tileset to display
-	.db $cc			;5 starting tile in vram
-	.db %00111101		;6 palette and config. vhoopppN; oo=priority. ppp=palette. N=nametable vh=flip
-	.dw $0			;7 x position
-	.dw 201			;9 y position
-	.db 0			;11 current frame in animation list
-	.db 0			;12 object command list to use	
-	.db 0			;13 object offset in object list.
-	.db 9			;14 palette number to upload for this sprite
-	.dw OamTypeTextbox	;15 object number
-
-	.db 0			;17 x-displacement
-	.db 0			;18 y-displacement
-	.db 4			;19 z-displacement
-	.db 0			;20 z-value for pseudo-3d scenes
-	.db 0			;21 collision subroutine
-	.db 0			;22 animation repeat counter for nop, must not be set up
-;23-25 left void for future expansion
-
-;custom variables differing between sprites:
-	.db 0			;26 spare variable
-	.db $80			;27 target x-pos /npc walking distance
-	.db 32			;28 target y-pos
-	.db 0			;29 current x-pos, must not be set up
-	.db 8			;30 current y-pos, must not be set up
-	.db 0			;void
-	.db 0			;void
-	.db 0			;void
-	.db 0			;void
-	.db 0			;void
-	.db 0			;void
-	.db 0			;void
-object command list format:
-an entry is always 2 bytes long, mostly consisting of a command byte and a parameter
-normally, one command from the list is executed per frame.
-".." means no parameter.
-if bit7 of command byte is set, execute the next command immediately.
-this is used to execute multiple commands per frame.
-
-control code:	function:
--00NN		create another object in object list. NN is the number of the object to create. searches for the next free slot in object list
--01..		deletes object from list(can only delete itself. if an object wants to delete another one, it has to do this via the subroutine)
--02XY		adds signed xy-vector to objects position.
--03TF		increment current tileset frame. TF=number of frames to advance
--04TF		set tileset frame. TF=tileset frame to set
--05PC		set palette and config PC=palette and config ;IMPORTANT!! if this is executed, the tile positions of an object bigger than 8x8 must be swapped!!
--06AF		goto frame in animation list. can be used to create infinite looping objects. AF=frame in animation list
--07CL		goto command list. always starts at position 0 in that command list and discards current command list. CL=command list to go to.
--08.b0		set/unset object screen-bound (with bit0 of parameter)
--09.b0		set/unset object subroutine enable (with bit0 of parameter)
--0aSS		set object subroutine. SS=subroutine number
--0bTS		set tileset. TS:number of tileset to use
--0cSE		play soundeffect
--0dFN		nop and wait for next frame(s). used for delays. FN specifies number of frames to wait. 0=wait one frame, 5=wait 6 frames etc
--0e..		inifite loop. object stays active
--0f..		terminate. used to end object list processing. marks object as inactive.
--10VS		set target speed vector. bits0-5: speed (0-2subpixel precision) bits 6,7: accel type (0=direct, 1=linear slow, 2=linear fast, 3=smooth). speed 0 disables vector speed calculation
--11VD		set target vector direction/angle. bits0-5: target direction ($00=up $10=right $20=down $30=left) bits 6,7: direction change type (0=direct, 1=linear slow, 2=linear fast, 3=smooth). clockwise/counterclockwise direction is determined by distance between current and target direction(alsways uses fastest/smallest angle)
--12NN		create object and put it to the coordinates of the calling object. NN=number of object to create
-
-sprite palettes start at cgram entry 128
-
-
-oam registers:
-$2101 - global sprite size select
-sprite tile location select: 0,4000,8000,c000
-$2102 - oam adress
-$2103 - oam table and priority rotation select
-$2104 - oam data. this is a doublewrite/read register.
-
-free space for sprites:
-$4000 bytes at $c000
-$20 bytes per 8x8 sprite = 512 tiles for sprites
-first sprite tile must always be blank
-
-
-size:	amount possible in terms of vram space:
-8x8	512
-16x16	128
-32x32	32
-
-for sprites bigger than 8x8, the vram tile data is seperated into horizontal rows, each 16 tiles (=512 bytes) apart.
-they are always 16 tiles apart, no matter if the sprites are 16,32 or 64 pixels in size
-heres a table what to upload where for different sized sprites:
-
-xsize:	ysize:	number of lines to upload:	number of bytes to transfer per line:
-8	8	1				32
-16	16	2				64
-32	32	4				128
-64	64	8				256
-16	32	4				64
-32	64	8				128
-
-
-
-
-initial setting for register $2101 gets loaded with
-graphics config file loader "SetBGMode" and put into variable "ObjSel", updated every vblank
-
-variables:
-ObjectListPointer	dw		;pointer to current object in object list, used to set direct register
-CurrentObjectNumber	db		;number of currently selected object in list
-OamBufferPointer	dw		;pointer to current sprite in oam buffer
-
-fixed variables:
-.define ObjectFileSize	16		;size of one object file
-
-routines in detail:
-InitOam:
-	-clears oam table buffer
-	-clears object memory
-
-CreateObject:
-	-upload object file to first free slot in object list
-	-upload current frame of tileset to vram
-		-calculate transfer size by object size
-		-calculate transfer source by object size*frame number
-		-calculate transfer target by starting tile in vram
-	-upload palette to vram according to palette number config
-	-set object offset in object list variable
-ObjectProcessor:
-	-check object list for active object
-		-write sprite(s) to oambuffer according to object file
-		-process animation list if enabled
-		-execute subroutine if enabled
-
-*/
-
-ObjectProcessSubroutine:
-	rep #$31
-	phx
-	ldx.b ObjectListPointerCurrent
-	lda.w ObjEntrySubRout,x
-	and.w #$ff				;max number of routines: 256
-	asl a
-	tax
-
-	php
-	phd
-	jsr (AniSubroutineJumpLUT,x)
-	pld
-	plp
-	plx
-	rts
-
-
-
-
-
-ObjectProcessAniList:
-	php
-ObjectProcessAniListYes:
-	rep #$31
-;load pointer to current animation list:	
-	lda.w ObjEntryAniList,x	;get number of list to use
-	and.w #$ff
-	asl a
-	phx
-	tax
-;	sta.b TempBuffer
-	lda.l (ObjectAnimationLUT+BaseAdress),x	;get relative pointer to object
-	plx
-
-	clc
-	adc.w #ObjectAnimationLUT		;calculate real pointer
-	sta.b ThreeBytePointerLo
-	
-	sep #$20
-	lda.b #(:ObjectAnimationLUT+BaseAdress>>16)
-	sta.b ThreeBytePointerBank
-
-;get pointer to currently active frame:
-
-	rep #$31
-	lda.w ObjEntryAniFrame,x
-	and.w #$ff
-	asl a
-	tay
-
-;get command
-	phx
-	lda.b [ThreeBytePointerLo],y		;get current command
-	sta.b OamAniListStraightRepeatFlag	;store for immediate repeat checking
-	pha
-	and.w #$1f				;mask off repeat flag, maximum number of commands: 32
-	asl a
-	tax
-
-	pla
-	phy
-	php
-	phd
-
-/*
-	rep #$31
-	pha
-	lda.b ObjectListPointerCurrent
-	clc
-	adc.w #ObjectList & $ffff
-	tcd
-	
-	pla
-*/	
-	
-	sep #$20
-	lda.b #0		;clear high byte
-	xba			;and put parameter into a
-;parameter is in a,8bit
-;direct register points to current object
-;bank is $7e
-	jsr (AniListJumpLUT,x)
-	
-
-	pld
-	plp
-	ply	
-	plx
-	sep #$20
-	lda.b OamAniListStraightRepeatFlag
-	bmi ObjectProcessAniListYes			;if bit7 is set, next command is executed immediately
-	
-	plp
-	rts
-
-AniListJumpLUT:
-	.dw AniListCreateObj			;0
-	.dw AniListDelete
-	.dw AniListMove
-	.dw AniListTileFrameInc
-	.dw AniListTileFrameSet
-	.dw AniListPalConfSet
-	.dw AniListGotoAniFrame
-	.dw AniListGotoAniList
-	.dw AniListMakeBGBound
-	.dw AniListSubroutineEnable
-	.dw AniListSetSubroutine		;10
-	.dw AniListTileSetSet
-	.dw AniListPlaySoundEffect
-	.dw AniListVoid
-	.dw AniListInfiniteLoop
-	.dw AniListEnd							;15
-	.dw AniListSetVectorSpeed
-	.dw AniListSetVectorDir
-	.dw AniListCreateObjPosition
-
-;does nothing, doesn't proceed to next animation command	
-AniListInfiniteLoop:
-	rts
-	
-AniListVoid:
-	ldx.b ObjectListPointerCurrent	
-
-
-	sta.w TempBuffer
-	lda.w TempBuffer
-	beq AniListVoidProceed			;if argument is 0, proceed to next frame directly
-
-
-	lda.w ObjEntryAniCmdRepeat,x		;if argument is not zero, but command list repeat is, we just encountered this void command. load new wait value.
-	bne AniListVoidDecrease			;if argument is not zero, we're on a repeated loop here. don't load new value, just decrease old one.
-	
-	lda.w TempBuffer
-	sta.w ObjEntryAniCmdRepeat,x
-	rts
-	
-;argument was already loaded, decrease
-AniListVoidDecrease:
-	dec a
-	sta.w ObjEntryAniCmdRepeat,x
-	beq AniListVoidProceed			;if repeat value just turned 0, we're done here, go to next command
-
-	rts
-
-AniListVoidProceed:
-;	ldx.b ObjectListPointerCurrent
-;	stz.w ObjEntryAniCmdRepeat,x		;not needed, but do it anyway just to be safe
-	inc.w ObjEntryAniFrame,x
-	rts
-	
-AniListCreateObj:
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x
-	jsr CreateObject
-	rts
-
-AniListCreateObjPosition:
-	rep #$31
-	tay																;save number of object to load
-	ldx.b ObjectListPointerCurrent		;get position of calling object
-	lda.w ObjEntryXPos,x							;save to stack
-	adc.w #8*16												;move one tile to the left
-	pha
-	lda.w ObjEntryYPos,x
-	clc
-	adc.w #8*16												;move one tile to the bottom
-	pha
-	inc.w ObjEntryAniFrame,x
-	tya
-	jsr CreateObject
-	ldx.b ObjectListPointerCurrent		;get position of newly-created object
-	pla
-	sta.w ObjEntryYPos,x							;update position
-	pla
-	sta.w ObjEntryXPos,x
-	
-	rts
-
-
-AniListGotoAniFrame:
-	ldx.b ObjectListPointerCurrent
-	sta.w ObjEntryAniFrame,x			;store new animation frame
-	rts
-
-AniListDelete:
-	ldx.b ObjectListPointerCurrent
-	sta.w ObjEntryType,x			;clear object type info and present flag
-	rts
-
-AniListMove:	
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x
-	pha
-	and.b #$f0			;get x-add
-	clc
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	bit.b #$08			;check if negative
-	beq AniListMoveXNotNeg
-	
-	and.b #$07	
-	eor.b #$ff			;xor to substract value
-	inc a
-AniListMoveXNotNeg:	
-	rep #$31
-	asl a						;subpixel precision
-	asl a
-	asl a
-	asl a
-	adc.w ObjEntryXPos,x
-	sta.w ObjEntryXPos,x
-	sep #$20
-	pla
-	and.b #$0f			;get x-add
-	bit.b #$08			;check if negative
-	beq AniListMoveYNotNeg
-	
-	and.b #$07
-	eor.b #$ff			;xor to substract value
-	inc a
-AniListMoveYNotNeg:	
-	rep #$31
-	and.w #$ff			;mask off high byte from x-position calculation
-	asl a						;subpixel precision
-	asl a
-	asl a
-	asl a
-	
-	adc.w ObjEntryYPos,x
-	sta.w ObjEntryYPos,x
-	sep #$20
-	rts
-
-AniListTileFrameInc:
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	clc	
-	adc.w ObjEntryTilesetFrame,x		;add increment number to tileset frame
-	sta.w ObjEntryTilesetFrame,x		;store new tileset frame
-	lda.w ObjEntryType,x
-	bit.b #%01000000			;check if active. if inactive/offscreen, dont waste time uploading a new frame
-	beq AniListTileFrameIncOffscreen
-
-	jsr CreateObjUploadSpriteFrame
-AniListTileFrameIncOffscreen:
-	rts
-
-AniListTileSetSet:
-	ldx.b ObjectListPointerCurrent
-	sta.w ObjEntryTileset,x			;set tileset frame
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	
-	jsr CreateObjUploadSpriteFrame
-	rts
-
-AniListTileFrameSet:
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	sta.w ObjEntryTilesetFrame,x		;set tileset frame
-	jsr CreateObjUploadSpriteFrame
-	rts
-
-AniListPalConfSet:
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	sta.w ObjEntryPalConf,x		;set palette and priority config
-	rts
-
-AniListGotoAniList:
-	ldx.b ObjectListPointerCurrent
-	sta.w ObjEntryAniList,x		;set animation list	
-	stz.w ObjEntryAniFrame,x		;reset animation frame
-	stz.b TempBuffer+10			;clear animation-command repeat flag
-	rts
-
-AniListMakeBGBound:
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	and.b #1				;get bit 0
-	clc
-	asl a					;move to correct location
-	asl a
-	asl a
-	asl a
-	asl a
-	sta.b TempBuffer
-	lda.w ObjEntryType,x		;get object type byte
-	and.b #$DF				;mask off bg bound flag
-	ora.b TempBuffer			;set flag according to command parameter
-	sta.w ObjEntryType,x		;get object type byte
-	rts
-
-AniListSubroutineEnable:
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	and.b #1				;get bit 0
-	clc
-	asl a					;move to correct location
-	asl a
-	asl a
-	sta.b TempBuffer
-	lda.w ObjEntryType,x		;get object type byte
-	and.b #$F7				;mask off bg bound flag
-	ora.b TempBuffer			;set flag according to command parameter
-	sta.w ObjEntryType,x		;get object type byte
-	rts
-
-AniListSetSubroutine:
-	ldx.b ObjectListPointerCurrent	
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	sta.w ObjEntrySubRout,x		;set new subroutine
-	rts
-	
-AniListPlaySoundEffect:	
-	rep #$31
-	ldx.b ObjectListPointerCurrent	
-	inc.w ObjEntryAniFrame,x		;increment animation frame	
-	and.w #$ff
-	jsr SpcPlaySoundEffectSimple
-	rts
-
-
-AniListEnd:
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	lda.w ObjEntryType,x		;
-	and.b #$ef				;mask off animate flag
-	sta.w ObjEntryType,x		;
-	rts
-
-AniListSetVectorSpeed:
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	sta.w ObjEntryVectorTarSpeed,x
-	and.b #%111111
-	cmp.b #$3f
-	bne AniListSetVectorSpeedNoOver
-
-	dec.w ObjEntryVectorTarSpeed,x
-
-AniListSetVectorSpeedNoOver:	
-	lda.w ObjEntryVectorSpeed,x
-	and.b #%1111111			;clear "target met" flag
-	sta.w ObjEntryVectorSpeed,x
-	rts
-
-AniListSetVectorDir:
-	ldx.b ObjectListPointerCurrent
-	inc.w ObjEntryAniFrame,x		;increment animation frame
-	sta.w ObjEntryVectorTarDir,x
-	and.b #%111111
-	sta.b TempBuffer
-	lda.w ObjEntryVectorDir,x
-	and.b #%111111
-	sta.b TempBuffer+1				;34
-	cmp.b TempBuffer				;28
-	beq AniListSetVectorDirEqual
-	bcs AniListSetVectorDirCurrBigger
-
-	lda.b TempBuffer
-	sec
-	sbc.b TempBuffer+1
-	cmp.b #32						;check if that distance is bigger than 180 degrees
-	bcs AniListSetVectorDirTargetCounterClock
-	bra AniListSetVectorDirTargetClockwise
-
-AniListSetVectorDirCurrBigger:
-	sec								;substract current from target to get distance between them
-	sbc.b TempBuffer				;c
-	cmp.b #32						;check if that distance is bigger than 180 degrees
-	bcc AniListSetVectorDirTargetCounterClock
-
-AniListSetVectorDirTargetClockwise:
-	lda.w ObjEntryVectorDir,x
-	and.b #%00111111				;clear "target met"
-	ora.b #%01000000				;set "clockwise"-flag
-	sta.w ObjEntryVectorDir,x
-	rts
-
-
-AniListSetVectorDirTargetCounterClock:
-	lda.w ObjEntryVectorDir,x
-	and.b #%00111111				;clear "target met" and turn direction flag(counter clockwise)
-	sta.w ObjEntryVectorDir,x
-	rts
-
-
-AniListSetVectorDirEqual:
-	lda.w ObjEntryVectorDir,x
-	ora.b #$80
-	sta.w ObjEntryVectorDir,x
-	rts
-
-;in: x,16bit:relative object pointer
-;out: x,16bit:relative pointer of next active object
-;if carry is set on return, all objects have been processed
-CheckActiveObject:
-;	rep #$31
-CheckActiveObjectLoop:
-	lda.l (ObjEntryType + $7e0000-1),x	;get object type byte (get -1 so that the bmi check still works in 16bit mode)
-;	xba
-;	nop
-	bmi CheckActiveObjectDone	;if a not-present object is found, end list processing
-
-
-	txa
-	clc
-	adc.w #ObjectFileSize			;increment slot pointer
-	tax
-	cpx.w #ObjectFileSize*63		;check if maximum number of objects reached, then step out(maybe spit out an error if needed)
-	bne CheckActiveObjectLoop
-
-CheckActiveObjectListDone:
-;	sep #$20
-	sec
-	rts
-
-
-;	bra CheckActiveObjectListDone	;this is to prevent a lockup if the list is full
-;	beq CheckActiveObjectListDone	;this is to prevent a lockup if the list is full
-	
-;	bra CheckActiveObjectLoop
-	
-CheckActiveObjectDone:
-;	rep #$31
-	stx.b ObjectListPointerCurrent		;store currently found object so that routines can check this back later
-;	sep #$20
-	clc
-	rts
-
-
-
-ObjectProcessor:
-	php
-	sep #$20
-	phb
-	lda.b #$7e
-	pha
-	plb
-	lda.b NMIOamUploadFlag		;don't process list if last frame wasn't uploaded first. needed to prevent sprite flicker due to dma'ing incomplete oam list(irq firing during oam processor)
-	bne ObjectProcessorExit
-	rep #$31
-	stz.w ColObjListPointer		;clear pointer in collision object list
-;	sep #$20
-;check for active objects
-	jsr ClearOamBufferPart		;only clear the part of the buffer that was actually written to last frame
-	jsr ClearOamPriorityBuffer
-;	jsr ClearPriorityZBuffer
-;	jsr ClearColObjList
-	ldx.w #0			;start at object 0
-
-ObjectProcessorLoop:
-	jsr CheckActiveObject		;check for active object
-	bcc ObjectProcessorNoExit	;if carry is set, all objects were processed
-	
-	jsr ZSortToOamBuffer
-;	rep #$31
-	stz.b ObjectListPointerCurrent
-	inc.b NMIOamUploadFlag				;initiate oam buffer upload
-ObjectProcessorExit:
-	plb
-	plp
-	rts
-
-ObjectProcessorNoExit:	
-
-;check if sprite needs to be drawn on screen:
-	lda.w ObjEntryType,x	;get object type byte
-;	bit.b #%01000000
-;	beq ObjProcInactive		;skip the oam write if bit isnt set
-	
-	bit.w #%00100000		;check if sprite is screenbound. if it is, dont check if the sprite is offscreen.
-	bne ObjProcDontCheckOnscreen
-
-ObjectProcessorCheckOnscreen:
-;	rep #$31
-	lda.w ObjEntryXPos,x					;remove precision
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	sta.w TempBufferTest
-
-	lda.w ObjEntryYPos,x					;remove precision
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	sta.w TempBufferTest+2
-	
-	lda.w ObjEntryXDisplacement,x	
-	and.w #$ff
-	eor.w #$ffff
-
-;	adc.w ObjEntryXPos,x		;check if sprite is left of screen
-	clc
-	adc.w TempBufferTest
-	clc
-	adc.w #32
-	cmp.b ScreenPixelPositionX
-	bcc ObjProcInactive
-	
-	lda.w ObjEntryXDisplacement,x	
-	and.w #$ff
-	clc	
-	adc.b ScreenPixelPositionX
-	
-	clc
-	adc.w #(TileBufferSizeX+1)*8	;check if sprite is right of screen
-;	cmp.w ObjEntryXPos,x
-	cmp.w TempBufferTest
-	bcc ObjProcInactive
-
-	lda.w ObjEntryYDisplacement,x
-	and.w #$ff
-	eor.w #$ffff
-	clc
-;	adc.w ObjEntryYPos,x		;check if sprite is on top of screen
-	adc.w TempBufferTest+2
-	clc
-	adc.w #32
-	cmp.b ScreenPixelPositionY
-	bcc ObjProcInactive
-
-	lda.w ObjEntryYDisplacement,x
-	and.w #$ff
-	clc
-	adc.b ScreenPixelPositionY
-	clc
-	adc.w #TileBufferSizeX*8	;check if sprite is below screen
-;	cmp.w ObjEntryYPos,x
-	cmp.w TempBufferTest+2
-	bcc ObjProcInactive
-
-
-ObjProcDontCheckOnscreen:
-	jsr ObjectSingleSpriteToOam
-
-;	sep #$20
-	lda.w ObjEntryType,x	;get object type byte
-	ora.w #%01000000
-	sta.w ObjEntryType,x	;set active flag
-
-
-	bra ObjProcActive
-ObjProcInactive:
-;	sep #$20
-	lda.w ObjEntryType,x	;get object type byte
-	and.w #%10111111
-	sta.w ObjEntryType,x	;clear active flag
-
-ObjProcActive:
-;	sep #$20
-	lda.w ObjEntryType,x	;get object type byte
-	phx
-	bit.w #%00010000
-	beq ObjProcNoAnim		;skip the oam write if bit isnt set
-	
-	jsr ObjectProcessAniList
-
-ObjProcNoAnim:
-	plx
-	stx.b ObjectListPointerCurrent	;must be saved cause ani list routines that create new sprites might rewrite it
-	phx
-;	sep #$20
-	lda.w ObjEntryType,x		;get object type byte
-	bit.w #%00001000
-	beq ObjProcNoSub		;skip the oam write if bit isnt set
-	
-	jsr ObjectProcessSubroutine
-
-ObjProcNoSub:
-;	sep #$20
-	plx
-	stx.b ObjectListPointerCurrent	;must be saved cause ani list routines that create new sprites might rewrite it
-	phx
-	lda.w ObjEntryType,x		;get object type byte
-	bit.w #%00000100
-	beq ObjProcNoColl		;skip the oam write if bit isnt set
-	
-	jsr CreateColListEntry
-
-ObjProcNoColl:
-	plx
-	stx.b ObjectListPointerCurrent	;must be saved cause ani list routines that create new sprites might rewrite it
-/*
-	lda.w ObjEntryVectorTarSpeed,x		;get vector target speed
-	and.w #%111111					;mask off target bit
-	beq ObjProcNoVectorMove			;skip vector move if vector speed is 0
-
-	jsr ObjVectorMoveHandler
-
-ObjProcNoVectorMove:
-*/
-;check if object is of gravity decaying type
-	lda.w ObjEntryType2,x	;get object type byte
-	
-	bit.w #%10000		;check if sprite is screenbound. if it is, dont check if the sprite is offscreen.
-	beq ObjProcNoGravity
-
-	jsr ObjProcUpdateGravity
-
-
-
-ObjProcNoGravity:
-;	rep #$31
-	txa
-	clc
-	adc.w #ObjectFileSize
-	tax
-	stx.b ObjectListPointerCurrent			;relative pointer to current object in objectlist
-
-	jmp ObjectProcessorLoop	
-	
-	plp
-	rts
-
-;upload collidable object information to a special list
-CreateColListEntry:
-	php
-	txy
-	ldx ColObjListPointer		;get pointer to currently active slot in col obj list
-	sep #$20
-;	lda.b #$80			;load col-obj present flag
-	lda.w ObjEntryColliSub,y	;get subroutine number and
-	ora.b #$80			;set enable flag
-	xba
-	lda.w ObjEntryListOffset,y	;load obj number in object list
-	rep #$31
-	sta.l ColObjList,x		;store in obj col list
-
-	lda.w ObjEntryXPos,y		;get x pos of obj and divide by 16
-	
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a
-	
-	inx
-	inx
-	sta.l ColObjList,x		;store in obj col list
-
-	lda.w ObjEntryYPos,y		;get y pos of obj and divide by 16
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a	
-	inx
-	inx
-	sta.l ColObjList,x		;store in obj col list
-	inx
-	inx
-	stx ColObjListPointer		;update pointer to next entry in collision list
-
-	tyx
-	plp
-	rts
-
-
-;in: 	a, 8bit: number of object to load
-;	x, 16bit: target low: x, high:y-position/8
-;in	y, 8bit: target z-position
-;uses TempBuffer0,1. maybe convert to use own temp area for better flexibility?
-CreateObjectPosition:
-	php
-	
-	rep #$31
-	stx.b CollisionPixelX
-	sty.b CollisionPixelY
-;	sty.b CollisionPixelY
-	and.w #$ff			;2byte pointer
-	asl a
-	tax				;put into x
-
-	phd
-	lda.w #0
-	tcd
-
-	sep #$20
-	phb
-	lda.b #$7e
-	pha
-	plb
-	rep #$31
-
-	lda.l (ObjectLUT+BaseAdress),x	;get relative pointer to object
-	clc
-	adc.w #ObjectLUT		;calculate real pointer
-	sta.b ThreeBytePointerLo
-	
-	sep #$20
-	lda.b #(:ObjectLUT+BaseAdress>>16)
-	sta.b ThreeBytePointerBank
-
-;check for free object space in object list:	
-;	rep #$31
-	ldx.w #0
-
-CreateObjectPositionCheckFreeSpaceLoop:
-	lda.w ObjEntryType,x	;get object type byte
-	bpl CreateObjectPositionCheckFreeSpaceDone	;if free, step out
-
-	rep #$31
-	txa
-	adc.w #ObjectFileSize			;increment slot pointer
-	tax
-	sep #$20
-	cpx.w #ObjectFileSize*63		;check if maximum number of objects reached, then step out(maybe spit out an error if needed)
-	beq CreateObjectPositionCheckFreeSpaceDone	;this is to prevent a lockup if the list is full
-	
-	bra CreateObjectPositionCheckFreeSpaceLoop
-	
-CreateObjectPositionCheckFreeSpaceDone:
-	rep #$31
-	stx.b ObjectListPointerCurrent			;relative pointer to current object in objectlist
-	txa
-	clc
-	lsr a
-	lsr a
-	lsr a
-	lsr a					;divide objectlist pointer by 16 to get current object number
-	sep #$20
-	sta.b CurrentObjectNumber
-
-	rep #$31
-	ldy.w #0
-	
-CreateObjectPositionUploadLoop:
-	lda.b [ThreeBytePointerLo],y		;get first byte of object file in rom
-	sta.w ObjEntryType,x
-	
-	inx
-	inx
-	iny
-	iny
-	cpy.w #(ObjectFileSize&$fffe)		;check if object file was uploaded, word-aligned
-	bne CreateObjectPositionUploadLoop
-
-	ldx.b ObjectListPointerCurrent
-
-	lda.w ObjEntryType,x	;get object type byte
-	bit.w #%100000		;check if screenbound
-	beq CreateObjectPositionNotScreenBound
-
-	lda.w ObjEntryType2-1,x	;pseudo-3d object?
-	bpl CreateObjectPositionNot3D
-
-	lda.b CollisionPixelX				;plot directly to loaded xy position if screenbound
-	and.w #$ff
-	clc
-	asl a						;multiply with 16, 3d high-precision value
-	asl a
-	asl a
-	asl a
-;	asl a
-;	asl a
-	
-	asl a
-	asl a
-	asl a
-	sta.w ObjEntryXPos,x
-	lda.b CollisionPixelX
-	and.w #$ff00
-	xba
-	clc
-	asl a						;multiply with 16, 3d high-precision value
-	asl a
-	asl a
-	asl a
-;	asl a
-;	asl a	
-
-	asl a
-	asl a
-	asl a	
-	sta.w ObjEntryYPos,x
-
-	lda.b CollisionPixelY				;store z-value
-	sep #$20
-	sta.w ObjEntryZDisplacement,x
-	rep #$31
-	bra CreateObjectPositionNotScreenBoundSkip
-
-
-
-CreateObjectPositionNot3D:	
-	lda.b CollisionPixelX				;plot directly to loaded xy position if screenbound
-	and.w #$ff
-	clc
-	asl a						;multiply by 8
-	asl a
-	asl a
-	
-	asl a												;add subpixel precision
-	asl a
-	asl a
-	asl a
-	
-	sta.w ObjEntryXPos,x
-	lda.b CollisionPixelX
-	xba
-	and.w #$ff
-	clc
-	asl a						;multiply by 8
-	asl a
-	asl a
-
-	asl a												;add subpixel precision
-	asl a
-	asl a
-	asl a
-
-	sta.w ObjEntryYPos,x
-
-
-	bra CreateObjectPositionNotScreenBoundSkip
-
-CreateObjectPositionNotScreenBound:
-	clc
-	lda.b CollisionPixelX
-	and.w #$ff
-	asl a					;multiply by 8
-	asl a
-	asl a
-
-	asl a												;add subpixel precision
-	asl a
-	asl a
-	asl a
-		
-	sta.w ObjEntryXPos,x
-	clc
-	lda.b CollisionPixelX
-	and.w #$ff00
-	xba 
-	asl a					;multiply by 8
-	asl a
-	asl a
-
-	asl a												;add subpixel precision
-	asl a
-	asl a
-	asl a	
-	sta.w ObjEntryYPos,x
-
-CreateObjectPositionNotScreenBoundSkip:
-
-;upload object number:
-;	ldx.b ObjectListPointer
-;	clc
-;	adc.w #(ObjectList & $ffff)
-;	clc
-;	adc.w #13				
-;	tax
-	lda.w #0
-	tay
-;	tax
-;	inx
-	sep #$20
-	lda.b CurrentObjectNumber
-	sta.w ObjEntryListOffset,x	;store in the object number offset in an object file
-
-	jsr CreateObjUploadSpriteFrame
-
-	jsr CreateObjUploadPalette
-
-;the animation list has to be executed at once in case objects create additional objects
-	ldx.b ObjectListPointerCurrent
-;	stx.b ObjectListPointerCurrent
-	phx
-	lda.w ObjEntryType,x	;get object type byte
-	bit.b #%00010000
-	beq ObjLoaderPositionNoAnim		;skip the oam write if bit isnt set
-	
-	jsr ObjectProcessAniList
-
-ObjLoaderPositionNoAnim:
-
-	lda.w ObjEntryType2,x		;increase max obj number if gravity particle present
-	bit.b #%10000
-	beq ObjLoaderPositionNoGravObj		;skip the oam write if bit isnt set
-	
-	jsr ObjectProcessGravObjInc
-
-ObjLoaderPositionNoGravObj:
-
-
-
-	plx
-	stx.b ObjectListPointerCurrent	;must be saved cause ani list routines that create new sprites might rewrite it
-
-	sep #$20
-
-	lda.w ObjEntryType,x	;get object type byte
-	bit.b #%00001000
-	beq ObjLoaderPositionNoSub		;skip the oam write if bit isnt set
-	
-	jsr ObjectProcessSubroutine
-
-ObjLoaderPositionNoSub:
-
-	plb
-	pld
-	plp
-	rts
-
-
-;upload palette:
-CreateObjUploadPalette:
-	lda.w ObjEntryType2,x
-	bit.b #%00100000					;don't upload palette if corresponding flag is set
-	bne CreateObjUploadPaletteCancel
-	
-	rep #$31
-	lda.w ObjEntryPalConf,x	;get palette config
-	sta.b TempBuffer
-	lda.w ObjEntryPalNumber,x	;get palette number
-	and.w #$ff			;2byte pointer
-	asl a				;2byte length
-	asl a
-	tax				;put into x
-	lda.l (SpritePaletteLUT+BaseAdress),x	;get relative pointer to object
-	clc
-	adc.w #SpritePaletteLUT		;calculate real pointer
-	sta.b ThreeBytePointerLo
-	
-	lda.l (SpritePaletteLUT+BaseAdress+2),x	;get length
-	and.w #$fe														;mask off bit0. palettes always have word entries. prevents uploader from crashing if invalid palette is being loaded
-	cmp.w #$20
-	bcs UploadObjPalNoOverflow
-
-	lda.w #$20								;never load palettes bigger than 32 bytes
-UploadObjPalNoOverflow:
-
-
-	sta.b TempBuffer+1
-	
-	lda.w #0
-	sep #$20
-	lda.b #(:SpritePaletteLUT+BaseAdress>>16)
-	sta.b ThreeBytePointerBank
-
-	rep #$31
-	lda.b TempBuffer
-	and.w #$E				;only get three palette bits
-	clc
-	lsr a					;rotate right to get palette number
-	clc
-	adc.w #8				;add sprite palette offset
-
-	
-	asl a					;multiply with 16 to get real start adress in palette buffer
-	asl a
-	asl a
-	asl a
-	asl a
-	
-	tax
-	
-	ldy.w #0
-CreateObjectPositionUploadPaletteLoop:
-	lda.b [ThreeBytePointerLo],y		;get first byte of object file in rom
-	sta.w PaletteBuffer & $ffff,x
-	
-	inx
-	inx
-	iny
-	iny
-	cpy.b TempBuffer+1		;check if object file was uploaded, word-aligned
-	bne CreateObjectPositionUploadPaletteLoop
-
-	sep #$20
-	inc.b NMIPaletteUploadFlag
-
-CreateObjUploadPaletteCancel:	
-	rts
-
-;in: a, 8bit: number of object to load
-CreateObject:
-	php
-	
-	rep #$31
-	and.w #$ff			;2byte pointer
-	sta.b TempBuffer
-	asl a
-	tax				;put into x
-
-	phd
-	lda.w #0
-	tcd
-	
-
-
-
-	sep #$20
-	phb
-	lda.b #$7e
-	pha
-	plb
-	rep #$31
-
-	lda.l (ObjectLUT+BaseAdress),x	;get relative pointer to object
-	clc
-	adc.w #ObjectLUT		;calculate real pointer
-	sta.b ThreeBytePointerLo
-	
-	sep #$20
-	lda.b #(:ObjectLUT+BaseAdress>>16)
-	sta.b ThreeBytePointerBank
-
-;check for free object space in object list:	
-;	rep #$31
-	ldx.w #0
-
-CreateObjectCheckFreeSpaceLoop:
-	lda.w ObjEntryType,x	;get object type byte
-	bpl CreateObjectCheckFreeSpaceDone	;if free, step out
-
-	rep #$31
-	txa
-	adc.w #ObjectFileSize			;increment slot pointer
-	tax
-	sep #$20
-	cpx.w #ObjectFileSize*63		;check if maximum number of objects reached, then step out(maybe spit out an error if needed)
-	beq CreateObjectCheckFreeSpaceDone	;this is to prevent a lockup if the list is full
-	
-	bra CreateObjectCheckFreeSpaceLoop
-	
-CreateObjectCheckFreeSpaceDone:
-	rep #$31
-	stx.b ObjectListPointerCurrent			;relative pointer to current object in objectlist
-	txa
-	clc
-	lsr a
-	lsr a
-	lsr a
-	lsr a					;divide objectlist pointer by 16 to get current object number
-	sep #$20
-	sta.b CurrentObjectNumber
-
-	rep #$31
-	ldy.w #0
-CreateObjectUploadLoop:
-	lda.b [ThreeBytePointerLo],y		;get first byte of object file in rom
-	sta.w ObjEntryType,x
-	
-	inx
-	inx
-	iny
-	iny
-	cpy.w #(ObjectFileSize&$fffe)		;check if object file was uploaded, word-aligned
-	bne CreateObjectUploadLoop
-	
-;upload object number:
-	ldx.b ObjectListPointerCurrent
-;	clc
-;	adc.w #(ObjectList & $ffff)
-;	clc
-;	adc.w #13				
-;	tax
-	lda.w #0
-	tay
-;	tax
-;	inx
-;	lda.b TempBuffer			;store number of object so other routines can clearly identify it.
-;	sta.w ObjEntryObjectNumber,x
-	sep #$20
-	lda.b CurrentObjectNumber
-	sta.w ObjEntryListOffset,x	;store in the object number offset in an object file
-
-	jsr CreateObjUploadSpriteFrame
-
-/*
-;upload palette:
-	rep #$31
-	lda.w ObjEntryPalConf,x	;get palette config
-	sta.b TempBuffer
-	lda.w ObjEntryPalNumber,x	;get palette number
-	and.w #$ff			;2byte pointer
-	asl a				;2byte length
-	asl a
-	tax				;put into x
-	lda.l (SpritePaletteLUT+BaseAdress),x	;get relative pointer to object
-	clc
-	adc.w #SpritePaletteLUT		;calculate real pointer
-	sta.b ThreeBytePointerLo
-	
-	lda.l (SpritePaletteLUT+BaseAdress+2),x	;get length
-	and.w #$fe				;word-align, no longer than 256 bytes
-	sta.b TempBuffer+1
-	
-	lda.w #0
-	sep #$20
-	lda.b #(:SpritePaletteLUT+BaseAdress>>16)
-	sta.b ThreeBytePointerBank
-
-	rep #$31
-	lda.b TempBuffer
-	and.w #$E				;only get three palette bits
-	clc
-	lsr a					;rotate right to get palette number
-	clc
-	adc.w #8				;add sprite palette offset
-
-	
-	asl a					;multiply with 16 to get real start adress in palette buffer
-	asl a
-	asl a
-	asl a
-	asl a
-	
-	tax
-	
-	ldy.w #0
-CreateObjectUploadPaletteLoop:
-	lda.b [ThreeBytePointerLo],y		;get first byte of object file in rom
-	sta.w PaletteBuffer & $ffff,x
-	
-	inx
-	inx
-	iny
-	iny
-	cpy.b TempBuffer+1		;check if object file was uploaded, word-aligned
-	bne CreateObjectUploadPaletteLoop
-
-	sep #$20
-	inc.b NMIPaletteUploadFlag
-*/
-	jsr CreateObjUploadPalette
-	
-	ldx.b ObjectListPointerCurrent
-;	stx.b ObjectListPointerCurrent
-;	sep #$20
-	lda.w ObjEntryType,x	;get object type byte
-	bit.b #%00010000
-	beq ObjLoaderNoAnim		;skip the oam write if bit isnt set
-	
-	jsr ObjectProcessAniList
-
-ObjLoaderNoAnim:
-	lda.w ObjEntryType2,x		;increase max obj number if gravity particle present
-	bit.b #%10000
-	beq ObjLoaderPositionNoGravObj2		;skip the oam write if bit isnt set
-	
-	jsr ObjectProcessGravObjInc
-
-ObjLoaderPositionNoGravObj2:
-
-	sep #$20
-
-	lda.w ObjEntryType,x	;get object type byte
-	bit.b #%00001000
-	beq ObjLoaderNoSub		;skip the oam write if bit isnt set
-	
-	jsr ObjectProcessSubroutine
-
-ObjLoaderNoSub:
-	rep #$30
-;	stz.b ObjectListPointerCurrent
-
-	plb
-	pld
-	plp
-	rts
-
-;upload current frame to vram
-;get sprite config and lookup transfer type
-CreateObjUploadSpriteFrame:
-	php
-	sep #$20
-	lda.w ObjEntryType2,x
-	bit.b #%01000000
-	beq CreateObjUploadSpriteFrameDontCancel
-
-;don't upload any sprite tiles if bit6 of object type 2 is set. this is used for the music notes and stuff like that where many sprites share the same tiles in order to minimize dma overhead.
-	plp
-	rts
-
-CreateObjUploadSpriteFrameDontCancel:	
-	rep #$31
-	lda.w ObjEntryType,x	;get sprite size bit
-	and.w #%10
-	clc
-	asl a				;put into bit3
-	asl a
-	sta.b TempBuffer
-	
-	
-	lda.b ObjSel
-	and.w #%11100000
-	clc
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	ora.b TempBuffer		;add sprite size bit
-	sta.b TempBuffer
-	asl a				;multiply by 3 to get pointer
-	clc
-	adc.b TempBuffer
-	phx
-
-	tax				;put into x
-	lda.l (ObjSizeLUT+BaseAdress),x	;get transfer length and number of bytes to transfer for this sprite
-	sta.b TempBuffer+8		;+8 is length, +9 is transfer number
-	lda.l (ObjSizeLUT+BaseAdress+2),x	;get transfer type
-	sta.b TempBuffer+14		;+14 is type
-	
-	plx
-;	rep #$31
-
-
-;	lda.w #80
-;	sta.b TempBuffer		;this is the number of tiles of one frame
-
-;	stz.b TempBuffer+1
-;	sep #$20
-	clc
-	lda.b TempBuffer+8		; length of one transfer and divide by 32 to get number of h-tiles
-	and.w #$ff
-	inc a				;increment once to get real length
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	sta.b TempBuffer
-
-	lda.b TempBuffer+9		; transfer number 16bit
-	and.w #$ff
-	sta.b TempBuffer+2
-	lda.w #0	
-	tay
-
-CreateObjCalcSizeLoop3:
-	cpy.b TempBuffer+2
-	beq CreateObjCalcSizeDone3
-
-	iny
-	adc.b TempBuffer
-	bra CreateObjCalcSizeLoop3
-
-CreateObjCalcSizeDone3:
-	sta.b TempBuffer		;store total number of tiles
-
-	lda.w ObjEntryTilesetFrame,x	;get current tileset frame
-	and.w #$ff
-	sta.b TempBuffer+2
-	lda.w #0	
-	tay
-
-CreateObjCalcSizeLoop2:
-	cpy.b TempBuffer+2
-	beq CreateObjCalcSizeDone2
-
-	iny
-	adc.b TempBuffer
-	bra CreateObjCalcSizeLoop2
-
-CreateObjCalcSizeDone2:
-	sta.b TempBuffer+2				;this is the first tile to be uploaded 
-
-	lda.w ObjEntryTileset,x	;get tileset number
-	and.w #$ff
-	sta.b TempBuffer+4				;multiply with 3
-	asl a
-	clc
-	adc.b TempBuffer+4
-	
-	txy
-	tax
-	lda.l (SpriteTilesetLUT+BaseAdress),x
-	sta.b TempBuffer+4
-	lda.l (SpriteTilesetLUT+1+BaseAdress),x
-	tyx
-;	and.w #$ff
-	sta.b TempBuffer+5
-	
-	lda.b TempBuffer+2				;get first tile and multiply with 32 to get actual byte offset
-	clc
-	asl a
-	asl a
-	asl a
-	asl a
-	asl a
-	clc
-	adc.b TempBuffer+4
-	bcc CreateObjCalcSourceNoWrap
-	
-	inc.b TempBuffer+6			;increment bank
-
-CreateObjCalcSourceNoWrap:	
-	sta.b TempBuffer+4			;store transfer source offset
-	sep #$20
-	lda.w ObjEntryPalConf,x	;get nametable bit(msb of sprites first tile)
-	and.b #1
-	xba
-	lda.w ObjEntryVramTile,x	;get target tile number
-;	and.w #$ff
-	rep #$31
-;	clc
-	asl a						;multiply by 16(bytesize is 32, but vram is word-aligned)
-	asl a
-	asl a
-	asl a
-	clc
-	adc.b SpriteTileOffsetVram			;add initial sprite offset
-	sta.b TempBuffer+10				;this is the vram target
-	phx						;push object list pointer
-	ldx.b DmaFifoPointer
-
-	lda.b TempBuffer+8				;get transfer length and increase by 1 to get real length 16bit
-	and.w #$ff
-	inc a			
-	sta.b TempBuffer+12
-
-CreateObjUploadTilesLoop:
-	rep #$31
-	lda.b TempBuffer+14					;transfer type
-	sta.l DmaFifoEntryType,x
-
-;store transfer target
-	lda.b TempBuffer+10
-	sta.l DmaFifoEntryTarget,x		;vram target 2116
-
-;store transfer source
-	lda.b TempBuffer+4
-	sta.l DmaFifoEntrySrcLo,x		;source 4202
-	lda.b TempBuffer+5
-	sta.l DmaFifoEntrySrcHi,x		;source 4203
-
-;store transfer length
-	lda.b TempBuffer+12			;get transfer length. not used except for 8x8 sprites, where it is 32 bytes
-	sta.l DmaFifoEntryCount,x		;length 4205
-/*
-;update vram target pointer:
-	lda.b TempBuffer+10
-	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBuffer+10
-*/	
-;update fifo buffer target:
-	txa						;update fifo entry pointer
-	clc
-	adc.w #DmaFifoEntryLength
-
-/*
-	tax
-	
-;update source pointer
-	lda.b TempBuffer+4
-	clc
-	adc.b TempBuffer+12
-	sta.b TempBuffer+4
-
-	sep #$20
-	dec.b TempBuffer+9				;decrement number of transfers
-	bne CreateObjUploadTilesLoop
-	
-;sprite tile transfer done
-	rep #$31	
-	txa						;update fifo entry pointer
-;	clc
-;	adc.w #DmaFifoEntryLength
-*/
-	sta.b DmaFifoPointer
-	plx
-	plp						;fetch object list pointer
-	rts
-
-
-/*
-;old version which created multiple transfers in fifo buffer
-CreateObjUploadSpriteFrame:
-CreateObjLookupSpriteSize:
-	php
-	rep #$31
-	lda.w ObjEntryType,x	;get sprite size bit
-	and.w #%10
-	clc
-	asl a				;put into bit3
-	asl a
-	sta.b TempBuffer
-	
-	
-	lda.b ObjSel
-	and.w #%11100000
-	clc
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	ora.b TempBuffer		;add sprite size bit
-	asl a				;multiply by 2 to get pointer
-	phx
-
-	tax				;put into x
-	lda.l (ObjSizeLUT+BaseAdress),x	;get transfer length and number of bytes to transfer for this sprite
-	plx
-	sta.b TempBuffer+8		;+8 is length, +9 is transfer number
-;	rep #$31
-
-
-;	lda.w #80
-;	sta.b TempBuffer		;this is the number of tiles of one frame
-
-;	stz.b TempBuffer+1
-;	sep #$20
-	clc
-	lda.b TempBuffer+8		; length of one transfer and divide by 32 to get number of h-tiles
-	and.w #$ff
-	inc a				;increment once to get real length
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	sta.b TempBuffer
-
-	lda.b TempBuffer+9		; transfer number 16bit
-	and.w #$ff
-	sta.b TempBuffer+2
-	lda.w #0	
-	tay
-
-CreateObjCalcSizeLoop3:
-	cpy.b TempBuffer+2
-	beq CreateObjCalcSizeDone3
-
-	iny
-	adc.b TempBuffer
-	bra CreateObjCalcSizeLoop3
-
-CreateObjCalcSizeDone3:
-	sta.b TempBuffer		;store total number of tiles
-
-	lda.w ObjEntryTilesetFrame,x	;get current tileset frame
-	and.w #$ff
-	sta.b TempBuffer+2
-	lda.w #0	
-	tay
-
-;this must be reprogrammed, too:
-CreateObjCalcSizeLoop2:
-	cpy.b TempBuffer+2
-	beq CreateObjCalcSizeDone2
-
-	iny
-	adc.b TempBuffer
-	bra CreateObjCalcSizeLoop2
-
-CreateObjCalcSizeDone2:
-	sta.b TempBuffer+2				;this is the first tile to be uploaded 
-
-	lda.w ObjEntryTileset,x	;get tileset number
-	and.w #$ff
-	sta.b TempBuffer+4				;multiply with 3
-	asl a
-	clc
-	adc.b TempBuffer+4
-	
-	txy
-	tax
-	lda.l (SpriteTilesetLUT+BaseAdress),x
-	sta.b TempBuffer+4
-	lda.l (SpriteTilesetLUT+1+BaseAdress),x
-	tyx
-;	and.w #$ff
-	sta.b TempBuffer+5
-	
-	lda.b TempBuffer+2				;get first tile and multiply with 32 to get actual byte offset
-	clc
-	asl a
-	asl a
-	asl a
-	asl a
-	asl a
-	clc
-	adc.b TempBuffer+4
-	bcc CreateObjCalcSourceNoWrap
-	
-	inc.b TempBuffer+6			;increment bank
-
-CreateObjCalcSourceNoWrap:	
-	sta.b TempBuffer+4			;store transfer source offset
-	sep #$20
-	lda.w ObjEntryPalConf,x	;get nametable bit(msb of sprites first tile)
-	and.b #1
-	xba
-	lda.w ObjEntryVramTile,x	;get target tile number
-;	and.w #$ff
-	rep #$31
-;	clc
-	asl a						;multiply by 16(bytesize is 32, but vram is word-aligned)
-	asl a
-	asl a
-	asl a
-	clc
-	adc.b SpriteTileOffsetVram			;add initial sprite offset
-	sta.b TempBuffer+10				;this is the vram target
-	phx						;push object list pointer
-	ldx.b DmaFifoPointer
-
-	lda.b TempBuffer+8				;get transfer length and increase by 1 to get real length 16bit
-	and.w #$ff
-	inc a			
-	sta.b TempBuffer+12
-
-CreateObjUploadTilesLoop:
-	rep #$31
-	lda #1					;transfer type normal dma
-	sta.l DmaFifoEntryType,x
-
-;store transfer target
-	lda.b TempBuffer+10
-	sta.l DmaFifoEntryTarget,x		;vram target 2116
-
-;store transfer source
-	lda.b TempBuffer+4
-	sta.l DmaFifoEntrySrcLo,x		;source 4202
-	lda.b TempBuffer+5
-	sta.l DmaFifoEntrySrcHi,x		;source 4203
-
-;store transfer length
-	lda.b TempBuffer+12				;get transfer length
-	sta.l DmaFifoEntryCount,x		;length 4205
-
-;update vram target pointer:
-	lda.b TempBuffer+10
-	clc
-	adc.w #32*16/2					;add one 16tile-line to vram target
-	sta.b TempBuffer+10
-;update fifo buffer target:
-	txa						;update fifo entry pointer
-	clc
-	adc.w #DmaFifoEntryLength
-	tax
-	
-;update source pointer
-	lda.b TempBuffer+4
-	clc
-	adc.b TempBuffer+12
-	sta.b TempBuffer+4
-
-	sep #$20
-	dec.b TempBuffer+9				;decrement number of transfers
-	bne CreateObjUploadTilesLoop
-	
-;sprite tile transfer done
-	rep #$31	
-	txa						;update fifo entry pointer
-;	clc
-;	adc.w #DmaFifoEntryLength
-	sta.b DmaFifoPointer
-	plx
-	plp						;fetch object list pointer
-	rts
-*/
-
-;first writes a sorted list of object priorities, then transfers these to oam
-ZSortToOamBuffer:
-	php
-	rep #$31
-	sep #$20
-	ldx.w #0				;reset pointer to priority list
-	lda.b OamZsortSpriteNumber		;exit immediatly if there are no priority sprites on the current screen. else, it keeps on going on forever
-	bne ZSortToOamBufferNoExit
-	
-	plp
-	rts
-	
-ZSortToOamBufferNoExit:	
-	sta.b TempBuffer+2			;counter for inner loop
-	sta.b TempBuffer+3			;counter for outer loop
-	stz.b TempBuffer			;clear "highest priority" variable
-
-	
-;	ldx.w #0				;reset pointer to priority list
-	txy					;reset pointer to zsort list
-	
-
-
-
-ZsortSortingInnerLoop:
-	lda.w OamZSortBuffer & $FFFF+4,y	;entry present?
-	bpl ZsortNotPresent
-
-;sprite present
-	lda.w OamZSortBuffer & $FFFF+5,y	;get priority
-	cmp.b TempBuffer			;check if bigger than last highest sprite
-	bcc ZsortNotBiggest
-	
-	sta.b TempBuffer			;new highest priority
-
-	rep #$31
-	tya					;get pointer in sprite list, save to sort listing
-	sta.w OamZSortObjList & $FFFF,x
-
-
-ZsortNotBiggest:
-ZsortNotPresent:
-	rep #$31
-	tya
-	adc.w #OamZSortBufferSize		;get next entry
-	tay
-	sep #$20
-
-	dec.b TempBuffer+2			;decrease inner counter	
-	bne ZsortSortingInnerLoop
-
-;sorted through all once
-	lda.b OamZsortSpriteNumber
-	sta.b TempBuffer+2			;set counter for inner loop	
-	stz.b TempBuffer			;clear highest
-
-;clear "present"-bit of highest in this round	
-	phy
-	lda.w OamZSortObjList & $FFFF,x		;get pointer to highest
-	tay
-	lda.w OamZSortBuffer & $FFFF+4,y	;clear "present"-bit
-	and.b #$7f
-	sta.w OamZSortBuffer & $FFFF+4,y
-	
-	ply
-	
-	inx					;figure out next one
-	inx
-	ldy.w #0				;reset source buffer pointer
-	
-	dec.b TempBuffer+3			;decrease counter
-	bne ZsortSortingInnerLoop
-
-ZSortToOamBufferDoneSorting:	
-;	lda.b OamZsortSpriteNumber
-	stz.b TempBuffer+2			;clear pointer in priority list, counter
-	ldx.b OamBufferPointer			;get oam pointer, write after priorityless sprites
-;	ldy.w #0
-
-ZSortWriteToOamLoop:
-	rep #$31				;get pointer to current priority list entry
-	lda.b TempBuffer+2
-	and.w #$ff
-	tay	
-
-	lda.w OamZSortObjList & $FFFF,y		;get first pointer
-	tay
-
-;copy data from zbuffer to oam buffer
-	lda.w OamZSortBuffer & $FFFF,y
-	sta.w OamBuffer & $ffff,x	;store in oam buffer
-	lda.w OamZSortBuffer & $FFFF+2,y
-	sta.w OamBuffer & $ffff+2,x	;store in oam buffer
-
-	phx
-	phy
-
-	txa
-	and.w #$01f0				;get byte target of size buffer
-;	and.w #$0100				;get byte target of size buffer
-;	xba					;divide by 16
-
-	lsr a					;divide by 16
-	lsr a
-	lsr a
-	lsr a
-	sta.b TempBuffer			;this is the 16bit pointer to the current byte in size buffer
-
-;calculate bit offset in spritesize buffer:	
-	txa
-	clc
-	and.w #$c				;get target bits of size buffer
-	lsr a					;shift right twice to get correct jump offset
-	tax
-	lda.w OamZSortBuffer & $FFFF+4,y
-	ldy.b TempBuffer
-	and.w #%11
-	jmp (PrioObjectProcessorSizeTableJTbl,x)
-	
-PrioObjectProcessorSizeTableJTbl:
-	.dw PrioObjProcSizeJtblBit0
-	.dw PrioObjProcSizeJtblBit1
-	.dw PrioObjProcSizeJtblBit2
-	.dw PrioObjProcSizeJtblBit3
-
-PrioObjProcSizeJtblBit3:
-	asl a
-	asl a
-PrioObjProcSizeJtblBit2:
-	asl a
-	asl a
-PrioObjProcSizeJtblBit1:
-	asl a
-	asl a
-PrioObjProcSizeJtblBit0:
-
-	ora.w OamPriorityBuffer & $ffff,y	;store in corresponding bits/bytes
-	sta.w OamPriorityBuffer & $ffff,y	;store in corresponding bits/bytes
-	ply
-	plx
-	lda.w #0
-;	sta.w OamZSortBuffer & $FFFF,y		;clear zsort buffer entries right after use so we dont have to clear the whole list each frame
-;	sta.w OamZSortBuffer & $FFFF+2,y
-;	sta.w OamZSortBuffer & $FFFF+3,y
-
-	inx
-	inx
-	inx
-	inx
-
-	sep #$20
-	lda.b TempBuffer+2			;process next entry
-	inc a
-	inc a
-	sta.b TempBuffer+2			;process next entry
-	lsr a
-	cmp.b OamZsortSpriteNumber		;done copying?
-
-	bne ZSortWriteToOamLoop
-	
-	stx.b OamBufferPointer
-	
-	plp
-	rts	
-
-;in: a,16bit: desired scanline to draw sprite to.
-;out: y,16bit: relative pointer to correct entry in zsort buffer
-ObjectZSortGetFreeSlot:
-;	php
-;	rep #$31
-;	tya
-	sta.b TempBuffer			;get desired scanline
-	asl a			;multiply by 5 to get pointer into zsort buffer
-	asl a
-	clc
-	adc.b TempBuffer
-	tay
-
-ObjectZSortGetFreeSlotLoop:
-	lda.w OamZSortBuffer & $FFFF,y
-	beq ObjectZSortGetFreeSlotDone 
-	
-	tya
-	sec				;increase scanline by one if theres a sprite here already
-	sbc.w #OamZSortBufferSize
-	bcc ObjZSortGetSlotUnderrun			
-	tay
-	bra ObjectZSortGetFreeSlotLoop
-
-
-ObjZSortGetSlotUnderrun:
-	ldy.w #210*OamZSortBufferSize			;select max entry
-	bra ObjectZSortGetFreeSlotLoop
-
-ObjectZSortGetFreeSlotDone:
-;	tya
-;	clc
-;	adc.w #OamZSortBuffer		;make this a direct pointer
-;	tay
-;	plp
-	rts
-
-ObjProcScreenBound:
-	sep #$20	
-	lda.w ObjEntryZDisplacement,x			;calculate priority?
-;	and.w #$ff												;only get z-priority
-	beq ObjProcScreenBoundNoPriorityCalc
-
-;****************************************************
-;write sprite to oam zsort buffer instead
-	ldy.b OamZsortBufferPointer		;get buffer pointer
-
-
-
-;	rep #$31
-
-	lda.w ObjEntryType2,x			;pseudo-3d sprite?
-	bmi ObjProc3dSprite
-
-
-	lda.w ObjEntryZDisplacement,x		;store z
-
-
-	sta.w OamZSortBuffer & $ffff+5,y
-	rep #$31
-	lda.w ObjEntryXPos,x	;get xy-coordinates
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a	
-;	sep #$20
-	sta.w OamZSortBuffer & $ffff,y	;store x coordinate
-;	rep #$31
-	lda.w ObjEntryYPos,x		;get xy-coordinates
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a
-	sep #$20	
-	sta.w OamZSortBuffer & $ffff+1,y		;store x coordinate
-	jmp ObjProcZsortWriteExit
-
-
-ObjProc3dSprite:
-	lda.w ObjEntryZDisplacement,x
-	eor.b #$ff					;invert priority for 3d sprites
-
-	sta.w OamZSortBuffer & $ffff+5,y
-
-	rep #$31
-	lda.w ObjEntryXPos,x	;get xy-coordinates
-	lsr a			;divide by 16, high precision position
-	lsr a
-	lsr a
-	lsr a
-;	lsr a
-;	lsr a
-	sep #$20
-	sta.w OamZSortBuffer & $ffff,y	;store x coordinate
-	rep #$31
-	lda.w ObjEntryYPos,x		;get xy-coordinates
-	lsr a			;divide by 16, high precision position
-	lsr a
-	lsr a
-	lsr a
-;	lsr a
-;	lsr a
-	sep #$20
-	sta.w OamZSortBuffer & $ffff+1,y		;store x coordinate
-	jmp ObjProcZsortWriteExit
-
-
-
-ObjProcScreenBoundNoPriorityCalc:	
-
-	rep #$31
-	lda.w ObjEntryXPos,x	;get xy-coordinates
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a	
-	sta.w OamBuffer & $ffff,y			;store x coordinate
-	lda.w ObjEntryYPos,x	;get xy-coordinates
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a
-	sep #$20
-	sta.w OamBuffer & $ffff+1,y		;store y coordinate
-	
-	jmp ObjProcDrawConfig
-
-ObjectSingleSpriteToOam:
-;dont upload directly to sprite buffer, but put sprite in a seperate 256entry-list according to y+ydisplacement value so the sprites get z-sorted. ;upload sprite to oam buffer:
-
-;	rep #$31
-	ldy.b OamBufferPointer			;get pointer to current oam buffer entry
-
-	lda.w ObjEntryType,x
-	bit.w #%00100000				;check if screenbound
-	bne ObjProcScreenBound
-
-
-	lda.w ObjEntryZDisplacement,x
-	and.w #$ff
-	beq ObjProcNoPriorityCalc
-
-ObjProcPriorityCalc:
-;****************************************************
-;write sprite to oam zsort buffer instead
-	ldy.b OamZsortBufferPointer		;get buffer pointer
-	lda.w ObjEntryYPos,x		;get xy-coordinates
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a
-	sta.b TempBuffer
-		
-	lda.w ObjEntryZDisplacement,x
-	and.w #$ff
-	clc
-;	adc.w ObjEntryYPos,x		;get xy-coordinates
-	adc.b TempBuffer
-	sec
-	sbc.b ScreenPixelPositionY	;substract screen position to get sprite position on screen. before doing this, we made sure the sprite is actually onscreen.
-
-	sep #$20
-	sta.w OamZSortBuffer & $ffff+5,y
-	rep #$31
-
-	lda.w ObjEntryXPos,x	;get xy-coordinates
-;	clc
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a
-;	adc.w #16			;add 16 because of left border
-	sec
-	sbc.w ObjEntryXDisplacement,x
-	sec
-	sbc.b ScreenPixelPositionX	;substract screen position to get sprite position on screen. before doing this, we made sure the sprite is actually onscreen.
-	sta.w OamZSortBuffer & $ffff,y	;store x coordinate
-	bcs ObjProcPriorSprNoWrap1		;if sprite wraps around left screen edge, carry is clear
-
-	lda.w ObjEntryType,x		;set x-position sign bit if sprite wraps around the edge
-	ora.w #%1
-	sta.w ObjEntryType,x
-	bra ObjProcPriorSprWrapDone
-
-ObjProcPriorSprNoWrap1:
-	lda.w ObjEntryType,x		;clear x-position sign bit if sprite wraps around the edge
-	and.w #$fffe
-	sta.w ObjEntryType,x
-	
-ObjProcPriorSprWrapDone:
-	lda.w ObjEntryYPos,x		;get xy-coordinates
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a	
-	sec
-	sbc.b ScreenPixelPositionY	;substract screen position to get sprite position on screen. before doing this, we made sure the sprite is actually onscreen.
-	sec
-	sbc.w ObjEntryYDisplacement,x
-	sep #$20
-	sta.w OamZSortBuffer & $ffff+1,y		;store x coordinate
-
-ObjProcZsortWriteExit:
-	lda.w ObjEntryType,x		;get size/x-sign bits
-	and.b #%11
-	ora.b #$80			;set "present" bit
-	sta.w OamZSortBuffer & $ffff+4,y
-	inc.b OamZsortSpriteNumber		;increment number of sortable sprites
-	rep #$31
-	lda.w ObjEntryVramTile,x	;starting tile and config
-	sta.w OamZSortBuffer & $ffff+2,y		;store tile and config
-	
-	tya						;calc new value for buffer
-	adc.w #OamZSortBufferSize
-	sta.b OamZsortBufferPointer
-	
-	rts
-;****************************************************
-
-
-
-
-ObjProcNoPriorityCalc:	
-	lda.w ObjEntryXPos,x	;get xy-coordinates
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a
-	clc
-;	adc.w #16			;add 16 because of left border
-	sec
-	sbc.w ObjEntryXDisplacement,x
-
-	sec
-	sbc.b ScreenPixelPositionX	;substract screen position to get sprite position on screen. before doing this, we made sure the sprite is actually onscreen.
-
-	sta.w OamBuffer & $ffff,y	;store x coordinate
-	bcs ObjProcSprNoWrap1		;if sprite wraps around left screen edge, carry is clear
-
-	lda.w ObjEntryType,x		;set x-position sign bit if sprite wraps around the edge
-	ora.w #%1
-	sta.w ObjEntryType,x
-	bra ObjProcSprWrapDone
-
-ObjProcSprNoWrap1:
-	lda.w ObjEntryType,x		;clear x-position sign bit if sprite wraps around the edge
-	and.w #$fffe
-	sta.w ObjEntryType,x
-
-	
-ObjProcSprWrapDone:
-	lda.w ObjEntryYPos,x	;get xy-coordinates
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a	
-	sec
-	sbc.b ScreenPixelPositionY	;substract screen position to get sprite position on screen. before doing this, we made sure the sprite is actually onscreen.
-	sec
-	sbc.w ObjEntryYDisplacement,x
-
-	sep #$20
-	sta.w OamBuffer & $ffff+1,y		;store x coordinate
-
-
-
-ObjProcDrawConfig:
-
-;calculate byte offset in spritesize buffer:	
-	rep #$31
-
-
-;	ldy.b OamBufferPointer			;get pointer to current oam buffer entry
-	phx
-	phy
-	tya
-	and.w #$1f0				;get byte target of size buffer
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	sta.b TempBuffer			;this is the 16bit pointer to the current byte in size buffer
-;calculate bit offset in spritesize buffer:	
-	tya
-	clc
-	and.w #$c				;get target bits of size buffer
-	lsr a					;shift right twice to get correct jump offset
-	tay
-	lda.w ObjEntryType,x		;get size/x-sign bits
-	tyx
-	ldy.b TempBuffer
-	and.w #%11
-	jmp (ObjectProcessorSizeTableJTbl,x)
-	
-ObjectProcessorSizeTableJTbl:
-	.dw ObjProcSizeJtblBit0
-	.dw ObjProcSizeJtblBit1
-	.dw ObjProcSizeJtblBit2
-	.dw ObjProcSizeJtblBit3
-
-ObjProcSizeJtblBit3:
-	asl a
-	asl a
-ObjProcSizeJtblBit2:
-	asl a
-	asl a
-ObjProcSizeJtblBit1:
-	asl a
-	asl a
-ObjProcSizeJtblBit0:
-
-	ora.w OamPriorityBuffer & $ffff,y	;store in corresponding bits/bytes
-	sta.w OamPriorityBuffer & $ffff,y	;store in corresponding bits/bytes
-		
-	ply
-	plx
-
-;	sep #$20
-
-
-
-	rep #$31
-	lda.w ObjEntryVramTile,x	;starting tile and config
-	sta.w OamBuffer & $ffff+2,y		;store tile and config
-
-	iny						;move pointer to next tile
-	iny
-	iny
-	iny
-	sty.b OamBufferPointer				;store new buffer to next oam object
-	
-	rts
-
-
-
-InitOam:
-	php
-	jsr ClearOamBuffer
-	jsr ClearOamPriorityBuffer
-	jsr ClearObjectList
-	
-	sep #$20
-	stz.w GravObjectCounter				;reset amount of gravity objects
-	stz.b NMIOamUploadFlag			;clear this flag so that oam processor is executed at least once (in case irq oam uploader fucks up)
-
-.IF DEBUG == 1
-	lda.b #1			;create cpu-usage object in every scene if debug is enabled
-	jsr CreateObject
-
-.endif		
-	plp
-	rts
-	
-ClearOamPriorityBuffer:
-	php
-
-	rep #$31
-	sep #$20
-	lda.b #0		;clear word: $0000
-	ldy.w #$20
-	ldx.w #OamPriorityBuffer&$ffff
-	jsr ClearWRAM		
-	
-
-	plp
-	rts
-/*
-ClearOamPriorityBuffer:
-	php
-	rep #$31
-	lda.w #$0000			;clear with y-position at line 255
-	ldx.w #$0020
-ClearOamPriorityBufferLoop:
-	sta.l (OamPriorityBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	bne ClearOamPriorityBufferLoop
-	plp
-	rts
-*/
-
-
-
-
-ClearOamBufferPart:
-/*
-	php
-	rep #$31
-	lda.w #$c900			;clear with y-position at line 201
-	ldx.b OamBufferPointer
-	bra ClearOamBufferLoop
-*/
-	php
-	rep #$31
-	sep #$20
-	lda.b #3		;clear word: $0000
-	ldy.b OamBufferPointer
-	beq ClearOamBufferPartNoTrans		;need to do this, else $ffff long transfer occurs
-	
-	ldx.w #OamBuffer&$ffff
-	jsr ClearWRAM
-ClearOamBufferPartNoTrans:	
-	rep #$31
-	stz.b OamBufferPointer
-	stz.b OamZsortBufferPointer
-	stz.b OamZsortSpriteNumber	
-	plp
-	rts
-
-	
-ClearOamBuffer:
-
-/*
-	php
-	rep #$31
-	lda.w #$c900			;clear with y-position at line 201
-	ldx.w #$0200
-ClearOamBufferLoop:
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	sta.l (OamBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-
-
-	bpl ClearOamBufferLoop
-*/
-
-
-	php
-
-	rep #$31
-	sep #$20
-	lda.b #3		;clear word: $0000
-	ldy.w #$200
-	ldx.w #OamBuffer&$ffff
-	jsr ClearWRAM		
-	
-	rep #$31
-	stz.b OamBufferPointer
-	stz.b OamZsortBufferPointer
-	stz.b OamZsortSpriteNumber
-	plp
-	rts
-
-
-
-
-ClearColObjList:
-	php
-
-	rep #$31
-	sep #$20
-	lda.b #0		;clear word: $0000
-	ldy.w #ColObjFileSize*32			;old one was: ldx.w #ColObjFileSize*32-2, maybe -2 needed?
-	ldx.w #ColObjList&$ffff
-	jsr ClearWRAM	
-	plp
-	rts
-
-
-/*
-	php
-	rep #$31
-
-	lda.w #0			;clear with y-position at line 201
-	ldx.w #ColObjFileSize*32-2
-ClearColObjListLoop:
-	sta.l (ColObjList &$ffff + $7e0000-2),x
-	dex
-	dex
-	bne ClearColObjListLoop
-
-	stz.w ColObjListPointer
-	plp
-	rts
-*/
-
-
-ClearZBuffer:
-	php
-
-	rep #$31
-	sep #$20
-	lda.b #0		;clear word: $0000
-	ldy.w #OamZSortBufferSize*256
-	ldx.w #OamZSortBuffer&$ffff
-	jsr ClearWRAM	
-	plp
-	rts
-	
-/*
-	php
-	rep #$31
-
-	lda.w #0			;clear with y-position at line 201
-	ldx.w #OamZSortBufferSize*256
-ClearZBufferLoop:
-	sta.l (OamZSortBuffer & $ffff + $7e0000-2),x
-	dex
-	dex
-	bne ClearZBufferLoop
-
-;	stz.w ColObjListPointer
-	plp
-	rts
-*/
-
-ClearObjectList:
-	php
-	rep #$31
-	sep #$20
-	lda.b #0		;clear word: $0000
-	ldy.w #ObjectFileSize*64
-	ldx.w #ObjectList&$ffff
-	jsr ClearWRAM	
-	plp
-	rts
-
-
-/*
-	php
-	rep #$31
-	lda.w #$0000
-	ldx.w #ObjectFileSize*64
-ClearObjectListLoop:
-	sta.l (ObjectList &$ffff + $7e0000-2),x
-	dex
-	dex
-	bne ClearObjectListLoop
-	plp
-	rts
-*/
-
-
-;in: a,16bit: type of objects to delete
-;uses TempBuffer
-;takes around 11 scanlines
-SeekDeleteObjects:
-	php
-	rep #$31
-	sta.b TempBuffer			;store 16bit compare number
-	ldx.w #0
-
-SeekDeleteObjectsLoop:
-	lda.l ObjEntryObjectNumber+$7e0000,x		;get object number
-	cmp.b TempBuffer
-	bne SeekDeleteObjectsNoMatch
-	
-	lda.w #0
-	sta.l ObjEntryType+$7e0000,x			;delete object if number matches.
-
-SeekDeleteObjectsNoMatch:
-	txa
-	clc
-	adc.w #ObjectFileSize			;goto next entry
-	tax
-	cpx.w #ObjectFileSize*64		;check all 64 entries.
-	bne SeekDeleteObjectsLoop
-
-	
-	plp
-	rts
-
-;in: a,16bit: type of object to seek
-;uses TempBuffer
-;takes around 11 scanlines max.
-;searches for first object of selected type.
-;returns relative pointer to object in x
-;if object was not found, carry is set
-SeekObject:
-	php
-	rep #$31
-	sta.b TempBuffer			;store 16bit compare number
-	ldx.w #0
-
-SeekObjectLoop:
-	lda.l ObjEntryObjectNumber+$7e0000,x		;get object number
-	cmp.b TempBuffer
-	bne SeekObjectNoMatch
-;match found:
-	plp
-	clc
-	rts
-
-
-SeekObjectNoMatch:
-	txa
-	clc
-	adc.w #ObjectFileSize			;goto next entry
-	tax
-	cpx.w #ObjectFileSize*64		;check all 64 entries.
-	bne SeekObjectLoop
-
-	
-	plp
-	sec
-	rts
-	
-;same as above, but don't reset pointer into obj list. useful for finding multiple objects of the same type
-SeekObjectContinue:
-	php
-	rep #$31
-	sta.b TempBuffer
-	bra SeekObjectLoop
-	
-	
-	
-
-ObjVectorMoveHandler:
-	php
-	rep #$31
-	sep #$20
-	ldx.b ObjectListPointerCurrent
-	lda.w ObjEntryVectorSpeed,x
-	bmi ObjVectorSpeedMet
-
-	and.b #%111111
-	sta.b TempBuffer
-	lda.w ObjEntryVectorTarSpeed,x
-	pha
-	and.b #%111111
-	sta.b TempBuffer+1	
-	pla									;get speed change mode (upper 2 bits) and use it as pointer to jump LUT
-	rol a
-	rol a
-	rol a
-	asl a
-	rep #$31
-	and.w #%110
-	phx
-	tax
-	sep #$20
-
-	jsr (ObjVectorSpeedChangeModeLUT,x)
-	
-	plx
-	sta.b TempBuffer+2					;store inc/dec value
-
-
-;speed inc/dec	
-	lda.b TempBuffer+1
-	cmp.b TempBuffer					;check if target speed is bigger than actual speed
-	bcs ObjVectorTarSpeedBiggerLinear
-
-;target speed is lower than actual speed
-	lda.b TempBuffer
-	sec
-	sbc.b TempBuffer+2		;#%1000			;decrease speed by one full unit
-	cmp.b TempBuffer+1		;has actual speed become => target?
-	bmi	ObjVectorTarSpeedMetLin		;has speed wrapped around to $ff? if yes, target has also been reached(only needed if target is smaller than 1.0)
-	bcs ObjVectorTarSpeedNotMetLinInc
-
-;target speed met:
-	bra ObjVectorTarSpeedMetLin
-
-
-;target speed is bigger than actual speed
-ObjVectorTarSpeedBiggerLinear:
-	lda.b TempBuffer
-	clc
-	adc.b TempBuffer+2		;#%1000			;increase speed by one full unit
-	cmp.b TempBuffer+1		;has actual speed become => target?
-	bcc ObjVectorTarSpeedNotMetLinInc
-
-ObjVectorTarSpeedMetLin:
-	lda.b TempBuffer+1			;if target speed has been met or exceeded, write target speed into current and set "speed met"-flag.
-	and.b #%111111
-	ora.b #$80
-
-ObjVectorTarSpeedNotMetLinInc:
-	sta.w ObjEntryVectorSpeed,x
-ObjVectorSpeedMet:	
-
-	rep #$31
-	ldx.b ObjectListPointerCurrent
-	lda.w ObjEntryVectorDir-1,x
-	bmi ObjVectorTargetDirMet
-
-
-	asl a
-	asl a
-	and.w #%1111110000000000			;put into high byte
-	sta.b TempBuffer
-	lda.w ObjEntryVectorTurnSpeed,x		;get subpixel precision, 5bits starting at bit3
-	asl a								;put into bits 5-9
-	asl a
-	and.w #%0000001111100000			;mask off unwanted stuff
-	ora.b TempBuffer
-	sta.b TempBuffer
-	lda.w ObjEntryVectorTarDir,x
-	
-	pha
-	xba
-	asl a
-	asl a
-	and.w #%1111110000000000			;put into high byte
-	sta.b TempBuffer+2
-	
-	pla
-	lsr a
-	lsr a								;get speed change mode (upper 2 bits) and use it as pointer to jump LUT
-	lsr a
-	lsr a
-	lsr a
-	
-	and.w #%110
-	phx
-	tax
-
-	jsr (ObjVectorDirChangeModeLUT,x)
-
-	plx
-	sta.b TempBuffer+4					;store inc/dec value
-
-
-;	lda.b TempBuffer+1
-;	cmp.b TempBuffer					;check if target speed is bigger than actual speed
-	lda.w ObjEntryVectorDir,x
-	bit.w #%01000000
-	bne ObjVectorRotateClockwise		;bcs ObjVectorTarSpeedBiggerLinear
-
-;rotate anti-clockwise to meet target dir
-	lda.b TempBuffer				;get current angle
-	cmp.b TempBuffer+2				;is target angle smaller? (=must 0 be crossed to reach target?)
-	bcs AntiClockwiseNoZeroCross
-
-;must cross 0 to reach target
-	sec
-	sbc.b TempBuffer+4				;substract speed value
-	bcs AntiClockwiseTargetNotMet		;if 0 wasn't passed, target value couldn't have possibly been reached
-	cmp.b TempBuffer+2				;compare target to new angle
-	bcc AntiClockwiseTargetMet			;target met if new angle is smaller than old	
-	bra AntiClockwiseTargetNotMet
-
-ObjVectorTargetDirMet:
-	jmp ObjVectorTargetDirMetLong
-
-
-AntiClockwiseNoZeroCross:
-	sec
-	sbc.b TempBuffer+4				;substract speed value
-	bcc AntiClockwiseTargetMet			;target met if angle wraps around through 0.
-	cmp.b TempBuffer+2				;compare target to new angle
-	bcc AntiClockwiseTargetMet			;target met if new angle is smaller than old
-	bra AntiClockwiseTargetNotMet
-	
-ObjVectorRotateClockwise:
-
-;rotate clockwise to meet target dir
-	lda.b TempBuffer				;get current angle
-	cmp.b TempBuffer+2				;is target angle smaller? (=must 0 be crossed to reach target?)
-	bcc ClockwiseNoZeroCross
-
-;must cross 0 to reach target
-	clc
-	adc.b TempBuffer+4				;add speed value
-	bcc AntiClockwiseTargetNotMet		;if 0 wasn't passed, target value couldn't have possibly been reached
-	cmp.b TempBuffer+2				;compare target to new angle
-	bcs AntiClockwiseTargetMet		;target met if new angle is bigger than old	
-	bra AntiClockwiseTargetNotMet
-	
-
-
-ClockwiseNoZeroCross:
-	clc
-	adc.b TempBuffer+4				;add speed value
-	bcs AntiClockwiseTargetMet		;target met if angle wraps around through 0.
-	cmp.b TempBuffer+2				;compare target to new angle
-	bcs AntiClockwiseTargetMet		;target met if new angle is bigger than old
-	bra AntiClockwiseTargetNotMet
-
-AntiClockwiseTargetMet:
-	lda.b TempBuffer+2				;target met, set target without subpixel as new angle
-	and.w #%1111110000000000
-	lsr a
-	lsr a
-	ora.w #$8000					;set "target met" flag
-	bra AntiClockwiseTargetWrite
-	
-AntiClockwiseTargetNotMet:
-	and.w #%1111111111100000		;angle with subpixel precision
-	lsr a
-	lsr a
-AntiClockwiseTargetWrite:	
-
-	sta.b TempBuffer				;save new angle
-	sep #$20
-	lda.w ObjEntryVectorDir,x
-	and.b #%01000000
-	ora.b TempBuffer+1				;save back new direction
-	sta.w ObjEntryVectorDir,x
-	
-	lda.w ObjEntryVectorTurnSpeed,x
-	and.b #%111
-	ora.b TempBuffer
-	sta.w ObjEntryVectorTurnSpeed,x
-
-
-
-ObjVectorTargetDirMetLong:	
-	rep #$31					;get current position in vector angle, 16 max
-	lda.w ObjEntryType2,x
-	and.w #$f
-	sta.b TempBuffer
-	lda.w ObjEntryVectorTurnSpeed,x	;get subpixel precision for later usage
-	and.w #%111
-	sta.b TempBuffer+2
-	lda.w ObjEntryVectorSpeed,x
-	and.w #%111111
-	pha
-	lda.w ObjEntryVectorDir,x	;get direction, multiply with 32, add current position in angle
-	and.w #%111111
-	asl a
-	asl a
-	asl a
-	asl a
-	asl a						
-	adc.b TempBuffer
-	clc
-	adc.w #VectorAngleCodeLUT
-	tax							;source offset
-	ldy.w #VectorAngleSMCode&$ffff	;target offset
-	
-	pla							;get vector speed
-	clc
-	adc.b TempBuffer+2			;add sub-pixel buffer
-	pha
-	and.w #%111
-	sta.b TempBuffer+2			;save back for next frame
-	
-	pla
-	lsr a						;remove sub-pixel precision
-	lsr a
-	lsr a
-	and.w #%111
-	pha
-	beq VectorAngleNoSpeed		;triggers when vector move distance is lower than 1 and prevents ram thrashing.
-	
-	dec a						;decrease length by one for mvn
-
-	.db $54						;MVN
-	.db $7e						;destination bank
-	.db :VectorAngleCodeLUT+$c0	;target bank
-
-	lda.w #$6b							;rtl opcode
-	sta.w $0,y							;store after sm-code. y conveniently points to the byte after the last one transferred by MVN.	
-	
-	ldx.b ObjectListPointerCurrent
-	lda.w ObjEntryYPos,x
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a	
-	
-	tay
-	lda.w ObjEntryXPos,x
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a
-	phx
-	tax
-	jsl VectorAngleSMCode
-	
-	txa
-	plx
-	asl a												;add subpixel precision
-	asl a
-	asl a
-	asl a	
-	sta.w ObjEntryXPos,x
-	tya
-	asl a												;add subpixel precision
-	asl a
-	asl a
-	asl a	
-	sta.w ObjEntryYPos,x
-
-VectorAngleNoSpeed:	
-	pla							;update vector angle position
-	clc
-	adc.b TempBuffer
-	and.w #$f
-	sta.b TempBuffer
-	
-	sep #$20
-
-	
-	ldx.b ObjectListPointerCurrent
-
-	lda.w ObjEntryType2,x				;update vector angle position
-	and.b #%11110000
-	ora.b TempBuffer
-	sta.w ObjEntryType2,x
-	
-	lda.w ObjEntryVectorTurnSpeed,x		;update vector speed sub-pixel position
-	and.b #%11111000
-	ora.b TempBuffer+2
-	sta.w ObjEntryVectorTurnSpeed,x
-
-
-	plp
-	rts	
-
-
-ObjVectorSpeedChangeModeLUT:
-	.dw ObjVectorSpeedChangeDirect
-	.dw ObjVectorSpeedChangeLinearSlow
-	.dw ObjVectorSpeedChangeLinearFast
-	.dw ObjVectorSpeedChangeLinearSmooth
-	
-ObjVectorSpeedChangeDirect:
-	lda.b #$40
-	rts	
-	
-ObjVectorSpeedChangeLinearSlow:
-	lda.b #1					;smallest possible unit, takes 64 frames max to reach target speed
-	rts
-	
-ObjVectorSpeedChangeLinearFast:
-	lda.b #8					;one full unit, takes 8 frames max to reach target speed
-	rts	
-
-
-;smooth: divide the difference between target and current speed by two and use that to alter the current speed
-ObjVectorSpeedChangeLinearSmooth:
-	lda.b TempBuffer+1
-	sec
-	sbc.b TempBuffer					;check if target speed is bigger than actual speed
-	bcc ObjVectorTarSpeedBiggerSmooth
-	
-	bra ObjVectorTarSpeedSmooth
-
-
-ObjVectorTarSpeedBiggerSmooth:
-	lda.b TempBuffer
-	sec
-	sbc.b TempBuffer+1
-
-ObjVectorTarSpeedSmooth:	
-	lsr a
-	bne ObjVectorTarSpeedMinOKSmooth
-	
-	lda.b #1							;minimum speed: 1
-	rts
-	
-ObjVectorTarSpeedMinOKSmooth:
-	cmp.b #8
-	bcc ObjVectorTarSpeedMaxOKSmooth
-	
-	lda.b #8							;maximum speed: 8
-ObjVectorTarSpeedMaxOKSmooth:	
-	rts
-	
-	
-ObjVectorDirChangeModeLUT:
-	.dw ObjVectorDirChangeDirect
-	.dw ObjVectorDirChangeLinearSlow
-	.dw ObjVectorDirChangeLinearFast
-	.dw ObjVectorDirChangeLinearSmooth
-	
-
-ObjVectorDirChangeDirect:
-	lda.w #$fc00
-	rts	
-	
-ObjVectorDirChangeLinearSlow:
-	lda.w #$20					;smallest possible unit, takes 64 frames max to reach target speed
-	rts
-	
-ObjVectorDirChangeLinearFast:
-	lda.w #$400					;one full unit, takes 8 frames max to reach target speed
-	rts	
-
-
-;smooth: divide the difference between target and current speed by two and use that to alter the current speed
-ObjVectorDirChangeLinearSmooth:
-	lda.b TempBuffer+2
-	sec
-	sbc.b TempBuffer					;check if target speed is bigger than actual speed
-	bcc ObjVectorDirTarSpeedBiggerSmooth
-	
-	bra ObjVectorDirTarSpeedSmooth
-
-
-ObjVectorDirTarSpeedBiggerSmooth:
-	lda.b TempBuffer
-	sec
-	sbc.b TempBuffer+2
-
-ObjVectorDirTarSpeedSmooth:	
-	lsr a
-	cmp.w #$20							;smaller than minimum speed?
-	bcs ObjVectorDirTarSpeedMinOKSmooth
-	
-	lda.w #$20							;minimum speed: 1
-	rts
-	
-ObjVectorDirTarSpeedMinOKSmooth:
-	cmp.w #$400
-	bcc ObjVectorDirTarSpeedMaxOKSmooth
-	
-	lda.w #$400							;maximum speed: 8
-ObjVectorDirTarSpeedMaxOKSmooth:	
-	rts
-	
-OamSubCreateParticles:
-;create a couple of particles, position and palette same as victim:
-;input: x=pointer to object that is emitting the particles
-;		a=number to add to the random number(0-3) of particles to generate. (valid ranges:0-3)
-;modifies:paltemp
-;calls: createobject (uses TempBuffers), updates random a couple of times
-	php
-	rep #$31
-	phx
-	sep #$20
-	pha
-	lda.b R4
-	and.b #%11
-	sta.b PalTemp
-	pla
-	and.b #%11
-	clc
-	adc.b PalTemp
-	beq ParticleCreateExit
-	sta.b PalTemp
-	
-CreateParticleLoop:
-	rep #$31
-	lda.w ObjEntryYPos,x
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a
-
-	lsr a
-	lsr a
-	lsr a
-	and.w #$ff
-	xba
-	sta.b TempBuffer
-
-	
-	lda.w ObjEntryXDisplacement,x
-	and.w #$ff
-	sta.b TempBuffer+2
-
-	lda.w ObjEntryXPos,x
-	lsr a										;remove subpixel precision
-	lsr a
-	lsr a
-	lsr a
-	sec
-	sbc.w #10
-
-	
-	lsr a
-	lsr a
-	lsr a
-	inc a
-	and.w #$ff
-	ora.b TempBuffer
-	tax
-	lda.w #54
-	jsr CreateObjectPosition
-	sep #$20
-
-	plx
-	lda.w ObjEntryPalConf,x
-	and.b #%1110
-	sta.b TempBuffer
-	phx
-	ldx.b ObjectListPointerCurrent
-	lda.w ObjEntryPalConf,x
-	and.b #%11110001
-	ora.b TempBuffer					;store palette of player for this particle
-	sta.w ObjEntryPalConf,x
-	jsr Random							;update random numbers so that all particles look different
-	jsr Random							;update random numbers so that all particles look different
-	dec.b PalTemp
-	bne	CreateParticleLoop
-
-ParticleCreateExit:
-	plx
-	plp
-	rts
-	
-ObjProcUpdateGravity:	
-	lda.w ObjEntryLifeCounter,x
-	and.w #$ff
-	beq ObjProcGravityKill
-
-	dec.w ObjEntryLifeCounter,x		;decrease life counter
-	lda.w ObjEntryXSpeed,x		;add speed x-dir
-	and.w #$ff
-	clc
-	adc.w #$ff80							;align in middle so that x-speed can be both positive and negative
-	clc
-	adc.w ObjEntryXPos,x
-	sta.w ObjEntryXPos,x
-	
-	lda.w ObjEntryGravity,x
-	and.w #$ff
-	clc
-	adc.w ObjEntryYSpeed,x
-	sta.w ObjEntryYSpeed,x
-	clc
-	adc.w ObjEntryYPos,x
-	sta.w ObjEntryYPos,x
-	lsr a										;remove subpixel prec.
-	lsr a
-	lsr a
-	lsr a
-	cmp.w GravityCutOffYPos	;check if object is too low and should be deleted
-	bcs ObjProcGravityKill
-	rts	
-	
-ObjProcGravityKill:
-	dec.w GravObjectCounter
-	stz.w ObjEntryType,x		;kill object if life is up
-	rts
-	
-	
-ObjectProcessGravObjInc:
-	php
-	sep #$20
-	lda.w GravObjectCounter
-	cmp.w MaxGravObjCount				;number bigger than max count?
-	bcc ObjectProcessGravObjNoDel
-
-	stz.w ObjEntryType,x					;delete object if count is too high
-	stz.w ObjEntryType2,x
-	plp
-	rts
-
-ObjectProcessGravObjNoDel:
-	inc.w GravObjectCounter
-	plp
-	rts	
-	

+ 0 - 94
snes/loader/routines/oamobjects.asm

@@ -1,94 +0,0 @@
-.Section "oam objects" superfree
-;relative pointers to objects:
-ObjectLUT:
-	.dw (Object000-ObjectLUT)
-	.dw (Object001-ObjectLUT)
-
-
-								
-Object000:
-	.db %11011010		;object type designation
-				;bit3=subroutine? if set, this object has its own subroutine that must be executed every frame
-				;bit4=animate? if set, this object is animated(a special table for each object specifies the exact animation with commands for tileloading, waiting, animation loop etc)
-				;bit5=screen-bound? if set, this object must move in accordance with background layer 0
-				;bit6=object active? if set, this object is active and needs to be processed. if clear, this sprite doesnt need to be processed
-				;bit7=object present? if set, this slot has an object. if clear, its considered empty and can be overwritten
-	.db %00000000		;object type designation 2
-	.db $02			;number of subroutine. executed if bit6 of object type is set
-	.db 0			;tileset to use
-	.db $00			;current "frame" of tileset to display
-	.db $08			;starting tile in vram
-	.db %00110110		;palette and config
-	.dw $80			;x position
-	.dw $80			;y position
-	.db 0			;current frame in animation list
-	.db 0			;object command list to use	
-	.db 0			;object offset in object list.
-	.db 0			;palette number to upload for this sprite
-	.dw 0			;object number
-
-	.db 0			;x-displacement
-	.db 0			;y-displacement
-	.db 0			;z-displacement
-	.db 0			;animation repeat counter for nop
-	.db 0			;collision subroutine
-	.db 0			;vector speed. 3bit + 3bit sub-pixel accuracy. msb set=target speed met.(speed=0: don't calc vector movement)
-	.db 0			;void
-	.db 0			;void
-	.db 0			;void
-	.db 7			;spare variable
-	.db 0			;spare variable
-	.db 0			;spare variable
-	.db 0			;spare variable
-	.db 0			;spare variable
-	.db 0			;spare variable
-
-
-
-;cpu usage indicator
-Object001:
-	.db %11101000	;object type designation
-					;bit0=X position sign of sprite(usually 0)
-					;bit1=Object size flag
-					;bit2=collidable
-					;bit3=subroutine? if set, this object has its own subroutine that must be executed every frame
-					;bit4=animate? if set, this object is animated(a special table for each object specifies the exact animation with commands for tileloading, waiting, animation loop etc)
-					;bit5=bg-bound? if set, this object must move in accordance with background layer 0
-					;bit6=object active? if set, this object is active and needs to be drawn. if clear, this sprite doesnt need to be drawn, but must be processed, anyway
-					;bit7=object present? if set, this slot has an object. if clear, its considered empty and can be overwritten
-	.db %00100000	;object type designation 2
-					;bit7=pseudo 3d sprite that needs to be moved according to z-value when background moves
-					;bit6=don't upload tiles for this sprite. useful for stuff like particles and such where lots of sprites share the same tiles.
-					;bit5=don't upload palette for this sprite.
-					;bits0-3: current position in vector angle LUT (didn't fit anywhere else)
-	
-	.db 1			;number of subroutine. executed if bit6 of object type is set
-	.db 0			;tileset to use
-	.db $00			;current "frame" of tileset to display
-	.db $ff			;starting tile in vram
-	.db %00110001	;palette and config
-	.dw 1*16			;x position
-	.dw 1			;y position
-	.db 0			;current frame in animation list
-	.db 0			;object command list to use	
-	.db 0			;object offset in object list.
-	.db 0			;palette number to upload for this sprite
-	.dw 0			;object number
-
-	.db 0			;x-displacement
-	.db 0			;y-displacement
-	.db 0			;z-displacement
-	.db 0			;animation repeat counter for nop
-	.db 0			;collision subroutine
-	.db 0			;vector speed. bit0-2:subpixel speed. bit3-5:pixel speed.  bit7 set: target speed met  
-	.db 0			;vector target speed. bit0-2:subpixel speed target. bit3-5:pixel speed target. bit6,7: movement type(direct, linear slow, linear fast, smooth)
-	.db 0			;vector direction. bit0-5:direction.0=facing up. bit6=turning direction.(set=clockwise) msb set=target direction met.
-	.db 0			;vector target dir. bit0-5:target direction.0=facing up.  bit6,7: movement type(direct, linear slow, linear fast, smooth)
-	.db 0			;subpixel buffer. bit0-2:vector speed subpixel buffer. bit3-7: direction turn speed sub-pixel buffer. 
-	.db 0			;spare variable
-	.db 0			;spare variable
-	.db 0			;spare variable
-	.db 0			;spare variable
-	.db 0			;spare variable
-
-.ends

+ 0 - 20
snes/loader/routines/oamsubroutines.asm

@@ -1,20 +0,0 @@
-AniSubroutineJumpLUT:
-	.dw AniSubroutineVoid		;0
-	.dw AniSubroutineCpuUsage
-
-
-AniSubroutineCpuUsage:
-	sep #$20
-	ldx.b ObjectListPointerCurrent
-	lda.w CpuUsageScanline
-	asl a												;add subpixel precision
-	asl a
-	asl a
-	asl a	
-	sta.w ObjEntryYPos,x
-	lda.b #16*16-1								;*16=subpixel precision
-	sta.w ObjEntryXPos,x
-	rts
-
-AniSubroutineVoid:
-	rts	

+ 0 - 2054
snes/loader/routines/oamvectoranglelut.asm

@@ -1,2054 +0,0 @@
-.Section "OamvectorangleLUT" superfree
-
-VectorAngleCodeLUT:
-	dey		;0 - q1, facing top
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey		;0 wrap
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey		;1
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey		;1 wrap
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey		;2
-	dey
-	dey
-	dey
-	inx			
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	dey		;2 wrap
-	dey
-	dey
-	dey
-	inx			
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	dey		;3
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey		;3 wrap
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey	
-	dey		;4
-	dey
-	inx
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey		;4 wrap
-	dey
-	inx
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey
-	dey
-	inx
-	dey
-	dey		;5
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey		;5 wrap
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey		;6
-	dey
-	inx
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	inx
-	dey		;6 wrap
-	dey
-	inx
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	inx	
-	dey		;7
-	inx
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	inx
-	dey		;7 wrap
-	inx
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	dey
-	inx
-	dey
-	inx
-	dey		;8
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey		;8
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	inx		;9
-	dey
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	dey
-	inx		;9 wrap
-	dey
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	dey
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	dey	
-	inx		;10
-	inx
-	dey
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	dey
-	inx		;10 wrap
-	inx
-	dey
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	dey
-	inx		;11
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx		;11 wrap
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx
-	inx
-	dey
-	inx	
-	inx		;12
-	inx
-	dey
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx		;12 wrap
-	inx
-	dey
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx		;13
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx		;13 wrap
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx		;14
-	inx
-	inx
-	inx
-	dey			
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	inx		;14 wrap
-	inx
-	inx
-	inx
-	dey			
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	inx		;15
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx		;15 wrap
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	dey
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx		;0 - q2, facing right
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx		;0 wrap
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx		;1
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx		;1 wrap
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx		;2
-	inx
-	inx
-	inx
-	iny			
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	inx		;2 wrap
-	inx
-	inx
-	inx
-	iny			
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	inx		;3
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx		;3 wrap
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx	
-	inx		;4
-	inx
-	iny
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx		;4 wrap
-	inx
-	iny
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx
-	inx
-	iny
-	inx
-	inx		;5
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx		;5 wrap
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx		;6
-	inx
-	iny
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	iny
-	inx		;6 wrap
-	inx
-	iny
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	iny	
-	inx		;7
-	iny
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	iny
-	inx		;7 wrap
-	iny
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	inx
-	iny
-	inx
-	iny
-	inx		;8
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx		;8
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	iny		;9
-	inx
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	inx
-	iny		;9 wrap
-	inx
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	inx
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	inx	
-	iny		;10
-	iny
-	inx
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	inx
-	iny		;10 wrap
-	iny
-	inx
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	inx
-	iny		;11
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny		;11 wrap
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny
-	iny
-	inx
-	iny	
-	iny		;12
-	iny
-	inx
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny		;12 wrap
-	iny
-	inx
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny		;13
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny		;13 wrap
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny		;14
-	iny
-	iny
-	iny
-	inx			
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	iny		;14 wrap
-	iny
-	iny
-	iny
-	inx			
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	iny		;15
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny		;15 wrap
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	inx
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny		;0 - q3, facing down
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny		;0 wrap
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny		;1
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny		;1 wrap
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny		;2
-	iny
-	iny
-	iny
-	dex			
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	iny		;2 wrap
-	iny
-	iny
-	iny
-	dex			
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	iny		;3
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny		;3 wrap
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny	
-	iny		;4
-	iny
-	dex
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny		;4 wrap
-	iny
-	dex
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny
-	iny
-	dex
-	iny
-	iny		;5
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny		;5 wrap
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny		;6
-	iny
-	dex
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	dex
-	iny		;6 wrap
-	iny
-	dex
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	dex	
-	iny		;7
-	dex
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	dex
-	iny		;7 wrap
-	dex
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	iny
-	dex
-	iny
-	dex
-	iny		;8
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny		;8
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	dex		;9
-	iny
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	iny
-	dex		;9 wrap
-	iny
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	iny
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	iny	
-	dex		;10
-	dex
-	iny
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	iny
-	dex		;10 wrap
-	dex
-	iny
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	iny
-	dex		;11
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex		;11 wrap
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex
-	dex
-	iny
-	dex	
-	dex		;12
-	dex
-	iny
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex		;12 wrap
-	dex
-	iny
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex		;13
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex		;13 wrap
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex		;14
-	dex
-	dex
-	dex
-	iny			
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	dex		;14 wrap
-	dex
-	dex
-	dex
-	iny			
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	dex		;15
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex		;15 wrap
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	iny
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex		;0 - q4, facing left
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex		;0 wrap
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex		;1
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex		;1 wrap
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex		;2
-	dex
-	dex
-	dex
-	dey			
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dex		;2 wrap
-	dex
-	dex
-	dex
-	dey			
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dex		;3
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex		;3 wrap
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex	
-	dex		;4
-	dex
-	dey
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex		;4 wrap
-	dex
-	dey
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex
-	dex
-	dey
-	dex
-	dex		;5
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex		;5 wrap
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex		;6
-	dex
-	dey
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dey
-	dex		;6 wrap
-	dex
-	dey
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dey	
-	dex		;7
-	dey
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dey
-	dex		;7 wrap
-	dey
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dex
-	dey
-	dex
-	dey
-	dex		;8
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex		;8
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dey		;9
-	dex
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dex
-	dey		;9 wrap
-	dex
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dex
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dex	
-	dey		;10
-	dey
-	dex
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dex
-	dey		;10 wrap
-	dey
-	dex
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dex
-	dey		;11
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey		;11 wrap
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey
-	dey
-	dex
-	dey	
-	dey		;12
-	dey
-	dex
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey		;12 wrap
-	dey
-	dex
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey		;13
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey		;13 wrap
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey		;14
-	dey
-	dey
-	dey
-	dex			
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dey		;14 wrap
-	dey
-	dey
-	dey
-	dex			
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dey		;15
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey		;15 wrap
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dex
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-	dey
-
-.ends
-				

+ 0 - 756
snes/loader/routines/printstring.asm

@@ -1,756 +0,0 @@
-/*
-tiny text output system for snes by d4s in 2006
-call every frame in nmi, should be executed before global palette upload: DMATileMapToVramBG3
-
-call every time a textstring should be loaded: LoadTextString
-
-
-text byte commands:
-
-#$00 - terminate string
-#$01 - set new offset, only executed if not first byte in string(has 2 additional bytes)
-#$02 - set font
-#$03 - draw string from special adress, but with fixed length(has 4 additional bytes, first byte length, last 3 bytes string vector, maximum string length: 32 letters)
-#$04 - draw string from special adress(has 3 additional bytes for string vector)
-#$05 - draw byte in hexadecimal(has 3 additional bytes for string vector)
-#$06 - draw byte in binary(has 3 additional bytes for string vector)
-#$07 - change palette number(AND'ed with 0x7)
-#$08 - draw byte in decimal
-
-
-
-
-variables needed:
-
-Bg3Status			bit 0=font and palette uploaded
-
-PrintStringThreeBytePointerLo
-PrintStringThreeBytePointerHi
-PrintStringThreeBytePointerBank
-CurrentStringTarget
-CurrentStringTargetHi
-FontSelector
-FrameCounterLo
-FixedStringLength
-PrintStringBuffer0
-PrintStringBuffer1
-PrintStringBuffer2
-PrintStringBuffer3
-PrintStringBuffer4
-PrintStringBuffer5
-PrintStringBuffer6
-PrintStringBuffer7
-PrintStringBuffer8
-PrintStringBuffer9
-PrintStringPalette			;real number of palette
-
-
-ram areas needed:
-Bg3Buffer
-PaletteBuffer
-
-
-data needed:
-BG38x8FontTiles
-BG38x8FontPalette
-TextStrings
-TextStringPTable
-ASCIITable
-
-static vars needed:
-FontTileConfig
-
-*/
-
-DMATilesToVramBG3:
-	php
-	rep #$30
-;	sep #$20
-	
-;	lda.b #$03			;set vram adress of bg3/4 tiles $6000
-;	lda.b BGTilesVram34
-;	and.w 
-;	sta.l $210c
-;	lda.b #$30			;bg3 tilemap @ vram $7000, 32x32 tiles
-;	sta $2109
-;	stz $2112			;set bg3 v-offset to $0000
-;	stz $2112
-
-	lda #0
-	jsr UploadFontBG3
-	jsr ClearBg3TilemapBuffer
-	plp
-	rts
-
-
-DMATileMapToVramBG3:
-	php
-	rep #$30
-	sep #$20
-	lda.b NMIBg3UploadFlag
-	beq DontDMATileMapToVramBG3
-
-	stz.b NMIBg3UploadFlag			;clear upload flag
-	ldx.b DmaFifoPointer
-	lda #1					;transfer type
-	sta.l DmaFifoEntryType,x	
-;DMATileMapToVramBG3DontUploadFont:
-	lda.b #$7e			;get source bank of tilemap buffer
-;	sta.w $4304			;Store the data bank of the source data
-	sta.l DmaFifoEntrySrcBank,x		;source 4304
-	
-	rep #$30			;accu 16bit
-	lda.w #Bg3MapBuffer&$ffff		;get source offset
-;	sta.w $4302
-	sta.l DmaFifoEntrySrcLo,x		;source 4302
-	lda.w #$0800
-;	sta.w $4305   			;Store the size of the data block
-	sta.l DmaFifoEntryCount,x		;length 4305
-;	ldx.w #$3000
-;	stx.w $2116			;vram adress $7000
-	lda.b BG3TilemapVram
-	and.w #%11111100		;mask off bg size bits
-	xba
-;	sta.w $2116
-	sta.l DmaFifoEntryTarget,x		;vram target 2116
-	
-	txa						;update fifo entry pointer
-	clc
-	adc.w #DmaFifoEntryLength
-	sta.b DmaFifoPointer
-
-	
-/*
-	sep #$20
-	lda #$80
-	sta $2115			;set VRAM transfer mode to word-access, increment by 1
-	lda #$01			;Set the DMA mode (word, normal increment)
-	sta $4300       
-	lda #$18    			;Set the destination register (VRAM gate)
-	sta $4301      
-	lda #$01    			;Initiate the DMA transfer
-	sta $420B
-*/
-DontDMATileMapToVramBG3:
-	plp
-	rts
-
-
-;in: a,8bit: number of font to upload
-UploadFontBG3:
-	php
-	rep #$31
-;	sep #$20
-	and.w #$ff	
-	asl a
-	asl a
-	tax					
-	lda.l (Bg38x8FontLUT+BaseAdress+2),x	;get font length
-	pha
-	lda.l (Bg38x8FontLUT+BaseAdress),x		;get font pointer
-	pha
-	
-	ldx.b DmaFifoPointer
-	sep #$20
-	lda #1					;transfer type
-	sta.l DmaFifoEntryType,x
-
-	lda.b #(:Bg38x8FontLUT+BaseAdress>>16)	;get source bank
-;	sta $4304			;Store the data bank of the source data
-	sta.l DmaFifoEntrySrcBank,x
-	rep #$30
-
-;	lda.w #BG38x8FontTiles
-;	sta $4302			;Store the data offset into DMA source offset
-	pla
-	sta.l DmaFifoEntrySrcLo,x		;source 4302
-
-;	lda.w #(BG38x8FontTilesEnd-BG38x8FontTiles)			;get size of font
-;	sta $4305 		  	;Store the size of the data block
-	pla
-	sta.l DmaFifoEntryCount,x		;length 4305
-
-	lda.b BGTilesVram34
-	and.w #$0f
-	clc
-	ror
-	ror
-	ror
-	ror
-	ror					;put into highest nibble
-	clc
-	adc.w #$400				;add $800 for tilemap
-;	sta $2116			;vram destination adress $1000(bg1 tilespace)
-	sta.l DmaFifoEntryTarget,x		;vram target 2116
-/*
-	sep #$20
-	lda #$80
-	sta $2115			;set VRAM transfer mode to word-access, increment by 1
-	lda #$01			;Set the DMA mode (word, normal increment)
-	sta $4300       
-	lda #$18  			;Set the destination register (VRAM gate)
-	sta $4301      
-	lda #$01    			;Initiate the DMA transfer
-	sta $420B
-*/
-
-	txa						;update fifo entry pointer
-	clc
-	adc.w #DmaFifoEntryLength
-	sta.b DmaFifoPointer
-
-
-DMAUploadPaletteBG3:
-	lda #(:BG38x8FontPalette+BaseAdress>>16)			;get source bank of tilemaps
-	sta PrintStringThreeBytePointerBank		;
-	rep #$30				;accu 16bit
-	lda.w #BG38x8FontPalette			;get source offset of tilemap
-	sta PrintStringThreeBytePointerLo
-	lda.w #(BG38x8FontPaletteEnd-BG38x8FontPalette)
-	sta.b TempBuffer
-;	ldx.w #$0008				;get length
-	
-	lda.w #FontTileConfig			;get palette number
-	and.w #%00011100		
-	lsr a					
-	lsr a
-	asl a
-	asl a
-	asl a
-	tax					;calculate starting offset in palette buffer and put in x
-	ldy.w #$0000				;clear target/source counter						
-DMAUploadPaletteBG3Loop:
-	lda [PrintStringThreeBytePointerLo],y				;load word from PrintStringThreeBytePointer
-	sta.w PaletteBuffer&$ffff,x				;store in bg3 pal buffer, palette 1
-	iny					;word-inc copy counter
-	iny
-	inx					;word-dec length counter
-	inx
-	dec TempBuffer
-	dec TempBuffer
-	bne DMAUploadPaletteBG3Loop		;done if length counter = 0
-	sep #$20
-	inc.b NMIPaletteUploadFlag
-	plp
-	rts
-
-
-LoadTextString:
-	pha
-	php
-	sep #$20
-	phb					;set data bank = wram
-	lda.b #$7e
-	pha
-	plb
-
-	lda.b #FontTileConfig
-	and.b #%00011100
-	sta.b PrintStringPalette
-	lda #(:TextStrings+BaseAdress>>16)			;get source bank of strings
-	sta PrintStringThreeBytePointerBank		;
-	rep #$30				;accu 16bit
-	txa					;get number of string
-	asl					;multiply by 2 to get pointertable entry
-	tax
-	lda.l (TextStringPTable+BaseAdress),x			;get source offset of string
-	sta PrintStringThreeBytePointerLo
-	ldy.w #$0000
-
-	lda [PrintStringThreeBytePointerLo],y		;get target buffer in wram
-	and.w #$fffe				;mask off bit 0 to ensure text is word-formatted properly
-	sta.w CurrentStringTarget
-	iny					;increment source position, word
-	iny			
-
-;process all script commands with jump table.
-;if processing a fixed length string, dont execute any script codes at all
-LoadTextStringFetchLetter:
-	rep #$30
-
-	tya
-	cmp.w #$01ff				;maximum string length: 256 bytes
-	bcs ScriptCommandExit
-	
-	sep #$20
-	lda #$00				;set upper byte of a to zero
-	xba
-	
-	
-	
-	lda.b FixedStringLength
-	beq NoFixedLengthDynaString
-	
-	lda.b FixedStringLength
-	dec a
-	sta.b FixedStringLength
-	cmp.b #$01
-	bne NoScriptCommand
-
-	jmp ScriptCommandExit
-
-NoFixedLengthDynaString:
-	rep #$30
-	lda [PrintStringThreeBytePointerLo],y		;check if we are processing a script command
-	and.w #$00f0
-	bne NoScriptCommand
-
-	lda [PrintStringThreeBytePointerLo],y		;get script command
-	and.w #$000f
-	clc
-	asl a
-	tax
-	jmp (ScriptCommandPointerTable,x)
-
-NoScriptCommand:
-	sep #$20
-
-TextStringNotTerminated:
-	lda [PrintStringThreeBytePointerLo],y
-	tax
-	lda.w FontSelector
-	beq TextStringNormalFont
-
-;special 8x16 font
-
-	lda.l (ASCIITable8x16+BaseAdress),x		;get tile value for current letter
-	
-;	clc
-	
-	
-	xba
-	lda.b #FontTileConfig			;palette and mirroring config for font tiles
-	and.b #%11100011			;clear old palette number
-	ora.b PrintStringPalette		;set palette number
-	xba
-	rep #$30				;now we have the full tileinfo for the letter
-	
-	ldx.w CurrentStringTarget	;get current position in tilemap
-	sta.l Bg3MapBuffer,x			;store upper tile
-	
-	clc
-	adc.w #$0010				;add 16 to get tile number of lower tile
-	sta.l (Bg3MapBuffer+$40),x			;store lower tile
-	
-	sep #$20
-	iny					;advance to next letter
-	inx
-	inx					;increment pointer in bg1 tilemap
-	stx.w CurrentStringTarget
-	
-	jmp LoadTextStringFetchLetter
-
-ScriptCommandExit:	
-	sep #$20
-	stz.b FixedStringLength
-	stz.w FontSelector		;reset font
-	inc.b NMIBg3UploadFlag
-	plb
-	plp
-	pla
-	rts
-
-
-;normal 8x8 font
-TextStringNormalFont:
-	lda.l (ASCIITable+BaseAdress),x		;get tile value for current letter
-;	sec
-;	sbc.b #$50
-	clc
-	adc.b #$30
-	xba
-	lda.b #FontTileConfig			;palette and mirroring config for font tiles
-	bcc TextStringNormalFontNoWrap
-	ora.b #1				;set tile number msb
-
-TextStringNormalFontNoWrap:
-	and.b #%11100011			;clear old palette number
-	ora.b PrintStringPalette		;set palette number
-	xba
-	rep #$30				;now we have the full tileinfo for the letter
-	
-	ldx.w CurrentStringTarget		;get current position in tilemap
-	sta.l Bg3MapBuffer,x
-	
-	sep #$20
-	iny					;advance to next letter
-	inx
-	inx					;increment pointer in bg1 tilemap
-	stx.w CurrentStringTarget
-	
-	jmp LoadTextStringFetchLetter
-
-ScriptCommandPrintByte:
-	rep #$30
-	iny
-	lda [PrintStringThreeBytePointerLo],y		;get ThreeByte adress of byte
-	pha
-	iny
-	lda [PrintStringThreeBytePointerLo],y
-	sta.w PrintStringThreeBytePointerHi		;and store in ThreeByte pointer
-	pla
-	sta.w PrintStringThreeBytePointerLo
-	ldy.w #$0000				;reset source pointer
-
-	sep #$20
-	lda.b #$04				;print 2 letters + overhang
-	sta.b FixedStringLength
-
-	lda [PrintStringThreeBytePointerLo],y
-	pha
-	lsr a					;get upper nibble
-	lsr a
-	lsr a
-	lsr a
-	and.b #$0f
-	clc
-	adc.b #$30				;add ASCII "0" to every letter
-	cmp.b #$3a				;check if bigger than ASCII "9"
-	bcc PrintByteNotA1
-
-	adc.b #$06				;add until ASCII "A" if bigger than 9(carry always set, so -1)
-PrintByteNotA1:
-	sta.w PrintStringBuffer0&$ffff		;store in first letter
-	pla
-	and.b #$0f
-	clc
-	adc.b #$30				;add ASCII "0" to every letter
-	cmp.b #$3a				;check if bigger than ASCII "9"
-	bcc PrintByteNotA2
-
-	adc.b #06				;add until ASCII "A" if bigger than 9(carry always set, so -1)
-PrintByteNotA2:
-	sta.w PrintStringBuffer0&$ffff+1		;store in second letter
-
-	lda.b #$7e				;
-	sta.b PrintStringThreeBytePointerBank
-	rep #$30
-	lda.w #PrintStringBuffer0&$ffff
-	sta.b PrintStringThreeBytePointerLo
-	jmp LoadTextStringFetchLetter
-		
-
-ScriptCommandPrintByteBinary:
-	rep #$30
-	iny
-	lda [PrintStringThreeBytePointerLo],y		;get ThreeByte adress of byte
-	pha
-	iny
-	lda [PrintStringThreeBytePointerLo],y
-	sta.b PrintStringThreeBytePointerHi		;and store in ThreeByte pointer
-	pla
-	sta.b PrintStringThreeBytePointerLo
-	ldy.w #$0000				;reset source pointer
-	tyx
-	
-	sep #$20
-	lda.b #10				;print 8 letters + overhang
-	sta.b FixedStringLength
-
-
-ScriptCommandBinaryConvLoop:
-	rep #$30
-	txa
-	asl a
-	tax
-	sep #$20
-
-
-	lda [PrintStringThreeBytePointerLo],y
-	jmp (ScriptCommandBinaryConvJtbl,x)
-
-ScriptCommandBinaryConvJtbl:
-	.dw ScriptCommandBinaryConv+0
-	.dw ScriptCommandBinaryConv+1
-	.dw ScriptCommandBinaryConv+2
-	.dw ScriptCommandBinaryConv+3
-	.dw ScriptCommandBinaryConv+4
-	.dw ScriptCommandBinaryConv+5
-	.dw ScriptCommandBinaryConv+6
-	.dw ScriptCommandBinaryConv+7
-	
-ScriptCommandBinaryConv:
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-
-	clc
-	and.b #01
-	adc.b #$30				;add until ASCII "0" or "1", depending on bit0
-
-	pha
-	rep #$30
-	txa
-	lsr a
-	tax
-	sep #$20
-	pla
-
-	sta.w PrintStringBuffer0&$ffff,x
-	inx
-	cpx.w #$0008
-	bne ScriptCommandBinaryConvLoop
-
-	lda.b #$7e				;
-	sta.b PrintStringThreeBytePointerBank
-	rep #$30
-	lda.w #PrintStringBuffer0&$ffff
-	sta.b PrintStringThreeBytePointerLo
-	jmp LoadTextStringFetchLetter
-
-
-
-ScriptCommandGetDynaStringFixLength:
-	sep #$20
-	iny
-	lda [PrintStringThreeBytePointerLo],y		;get string length
-	inc a
-	inc a
-	and.b #$1f					;maximum string length: 32 letters
-	sta.b FixedStringLength
-
-	
-ScriptCommandGetDynaString:
-	rep #$30
-	iny
-	lda [PrintStringThreeBytePointerLo],y		;get ThreeByte adress of dynamic string
-	pha
-	iny
-	lda [PrintStringThreeBytePointerLo],y
-	sta.w PrintStringThreeBytePointerHi		;and store in ThreeByte pointer
-	pla
-	sta.w PrintStringThreeBytePointerLo
-	ldy.w #$0000				;reset source pointer
-	jmp LoadTextStringFetchLetter
-	
-ScriptCommandNewPosition:
-	rep #$30
-	iny
-	lda [PrintStringThreeBytePointerLo],y		;get new offset in bg3 buffer
-	and.w #$fffe
-	sta.w CurrentStringTarget
-	iny
-	iny
-	lda.w #$0000
-	sep #$20
-	stz.w FontSelector		;reset font
-	jmp LoadTextStringFetchLetter
-
-ScriptCommandNewFont:
-	sep #$20
-	lda.w FontSelector
-	eor.b #$01				;xor bit 0
-	sta.w FontSelector		;save to font selection var
-	iny					;increment string pointer
-	jmp LoadTextStringFetchLetter
-
-
-ScriptCommandChangePalette:
-	sep #$20
-	iny
-	lda [PrintStringThreeBytePointerLo],y	;get new palette number
-	asl a
-	asl a
-	and.b #%00011100			;maximum number of palettes:8, move to correct location in tile config
-	
-	sta.b PrintStringPalette
-	iny					;increment string pointer
-	jmp LoadTextStringFetchLetter
-
-
-
-
-
-ScriptCommandVoid:
-	jmp ScriptCommandExit			;exit if an unimplemented script code is executed
-	
-StringSpace:
-	ldx.w CurrentStringTarget
-	inx
-	inx					;increment target buffer pointer by 2
-	stx.w CurrentStringTarget
-	iny					;increment string pointer
-	rts
-	
-HdmaFontPaletteGradient:
-	rts
-
-
-;alternates every 64 frames between 2 consecutive textstrings
-;in: x,16bit: number of first textstring
-FlashTextString:
-	php
-	rep #$30
-	sep #$20
-	lda.w FrameCounterLo
-	bit #$20
-	beq FlashTextStringShowFirstString
-
-	inx						;get next textstring
-
-FlashTextStringShowFirstString:
-
-	jsr LoadTextString
-
-	plp
-	rts
-
-
-ScriptCommandPointerTable:
-	.dw ScriptCommandExit				;0
-	.dw ScriptCommandNewPosition
-	.dw ScriptCommandNewFont
-	.dw ScriptCommandGetDynaStringFixLength
-	.dw ScriptCommandGetDynaString
-	.dw ScriptCommandPrintByte			;5
-	.dw ScriptCommandPrintByteBinary
-	.dw ScriptCommandChangePalette
-	.dw ScriptCommandPrintByteDecimal
-	.dw ScriptCommandVoid
-	.dw ScriptCommandVoid				;10
-	.dw ScriptCommandVoid
-	.dw ScriptCommandVoid
-	.dw ScriptCommandVoid
-	.dw ScriptCommandVoid
-	.dw ScriptCommandVoid
-
-
-ScriptCommandPrintByteDecimal:
-	rep #$30
-	iny
-	lda [PrintStringThreeBytePointerLo],y		;get ThreeByte adress of byte
-	pha
-	iny
-	lda [PrintStringThreeBytePointerLo],y
-	sta.b PrintStringThreeBytePointerHi		;and store in ThreeByte pointer
-	pla
-	sta.b PrintStringThreeBytePointerLo
-	ldy.w #$0000				;reset source pointer
-	tyx
-	
-	sep #$20
-	lda.b #5				;print 8 letters + overhang
-	sta.b FixedStringLength
-
-;have 3 variables, hexa value, a hexa counter and decimal(word).
-;increment decimal word and hexa counter until hexa value is reached.
-;if hexa counter=a: add 7 to go to 10
-
-	rep #$31
-
-	stz.b TempBuffer+2			;hex counter
-	stz.b TempBuffer+4			;decimal counter
-	
-	lda [PrintStringThreeBytePointerLo],y
-	and.w #$ff
-	sta.b TempBuffer			;target hex value
-	
-	beq DeciConvPrint			;skip counting if zero
-
-ScriptCommandDecimalConvLoop:	
-	
-	inc.b TempBuffer+4			;inc decimal
-	lda.b TempBuffer
-	lda.b TempBuffer+4
-	and.w #$f
-	cmp.w #$a
-	bne DeciConvNoOverf1
-
-	lda.b TempBuffer+4
-	clc
-	adc.w #6
-	sta.b TempBuffer+4
-
-DeciConvNoOverf1:
-	lda.b TempBuffer+4
-	and.w #$f0
-	cmp.w #$a0
-	bne DeciConvNoOverf2
-
-	lda.b TempBuffer+4
-	clc
-	adc.w #$60
-	sta.b TempBuffer+4
-
-
-
-DeciConvNoOverf2:
-
-	dec.b TempBuffer
-	bne ScriptCommandDecimalConvLoop
-
-DeciConvPrint:
-;print to buffer
-	sep #$20
-	lda.b TempBuffer+5
-	and.b #$f
-	sta.b TempBuffer+6
-	bne DeciConvPrint1			;dont print leading zero
-	
-	lda.b #$f0
-DeciConvPrint1:
-	clc
-	adc.b #$30				;add until ASCII "0" or "1", depending on bit0
-	sta.w PrintStringBuffer0&$ffff
-
-
-	lda.b TempBuffer+4
-	lsr a
-	lsr a
-	lsr a
-	lsr a
-	and.b #$f
-	bne DeciConvPrint2			;dont print leading zero
-	cmp.b TempBuffer+6
-	bne DeciConvPrint2
-	
-	lda.b #$f0
-DeciConvPrint2:
-
-	clc
-	adc.b #$30				;add until ASCII "0" or "1", depending on bit0
-	sta.w PrintStringBuffer0&$ffff+1
-
-	lda.b TempBuffer+4
-	and.b #$f
-	clc
-	adc.b #$30				;add until ASCII "0" or "1", depending on bit0
-
-	sta.w PrintStringBuffer0&$ffff+2
-
-
-
-	
-	
-	
-
-;	sep #$20
-	lda.b #$7e				;
-	sta.b PrintStringThreeBytePointerBank
-	rep #$30
-	lda.w #PrintStringBuffer0&$ffff
-	sta.b PrintStringThreeBytePointerLo
-	jmp LoadTextStringFetchLetter
-
-MessagePendingDelete:
-	php
-	rep #$31
-;	sep #$20
-	lda.w MessageDeleteCounter
-	beq MessagePendingDeleteInactive
-	cmp.w #1
-	bne MessagePendingDec
-
-	ldx.w #52
-	jsr LoadTextString		;delete message if counter is 1
-
-MessagePendingDec:	
-	dec.w MessageDeleteCounter
-MessagePendingDeleteInactive:	
-	plp
-	rts
-	

+ 0 - 40
snes/loader/routines/randomnumbergen.asm

@@ -1,40 +0,0 @@
-Random:
-	php
-	sep #$20
-	LDA R3
-	STA R4								;R4=R3
-	LDA R2
-	STA R3								;R3=R2
-	LDA R1
-	STA R2								;R2=R1
-	CMP R3
-	BMI R3_Greater				;If R3>R2 Then Goto R3_Greater
-	
-	LDA R3
-	CLC
-	ADC R4
-	clc
-	eor.w JoyPortBuffer&$ffff			;use button presses for rng aswell
-	eor.w JoyPortBuffer&$ffff+2
-	eor.w JoyPortBuffer&$ffff+4
-	eor.w JoyPortBuffer&$ffff+6
-	eor.w JoyPortBuffer&$ffff+8
-	eor.w JoyPortBuffer&$ffff+10
-	eor.w JoyPortBuffer&$ffff+12
-	eor.w JoyPortBuffer&$ffff+14
-	eor.b FrameCounterLo
-
-	STA R1								;R1=R3+R4 MOD 256
-	plp
-	RTS									 ;Return R1
-	
-R3_Greater:
-	CLC
-	ADC R4
-	clc
-	eor.w JoyPortBuffer&$ffff+8
-	eor.b FrameCounterLo
-
-	STA R1								;R1=R2+R4 MOD 256
-	plp
-	RTS									 ;Return R1

+ 0 - 34
snes/loader/routines/samplepacks.asm

@@ -1,34 +0,0 @@
-.Section "SamplepackLUT" superfree				
-PtPlayerSamplePackPointertable:
-		.dw SamplePack0
-		.db (:SamplePack0+BaseAdress>>16)
-
-.ends
-
-.Section "sample pack 0" superfree
-SamplePack0:
-	.dw (SamplePack0End-SamplePack0)
-
-SamplePackStart0:
-	.db 1				;number of samples in this pack
-
-Sample0Header:
-	.dw (Sample0-SamplePackStart0)	;relative pointer to sample	
-	.dw (Sample0-SamplePackStart0)	;relative loop pointer
-	.db $7f				;volume l
-	.db $7f				;volume r
-	.dw $400			;pitch
-	.dw $0000			;adsr
-	.db %00011111				;gain
-	.db 0
-	.db 0
-	.db 0
-	.db 0
-	.db 0
-
-
-Sample0:
-	.incbin "data/sounds/hit.brr"
-
-SamplePack0End:
-.ends

+ 0 - 74
snes/loader/routines/sinetables.asm

@@ -1,74 +0,0 @@
-SineTableLUT:
-	.dw SinTab1
-	.dw SinTab2
-
-
-SinTab1:
-
-.byte  2 , 3 , 5 , 6 , 8 , 9 , 11 , 13 
-.byte  14 , 16 , 17 , 19 , 20 , 22 , 23 , 25 
-.byte  27 , 28 , 30 , 31 , 33 , 34 , 36 , 37 
-.byte  39 , 40 , 42 , 43 , 45 , 46 , 48 , 49 
-.byte  50 , 52 , 53 , 55 , 56 , 58 , 59 , 60 
-.byte  62 , 63 , 64 , 66 , 67 , 68 , 70 , 71 
-.byte  72 , 74 , 75 , 76 , 78 , 79 , 80 , 81 
-.byte  82 , 84 , 85 , 86 , 87 , 88 , 89 , 91 
-.byte  92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 
-.byte  100 , 101 , 102 , 103 , 104 , 105 , 106 , 106 
-.byte  107 , 108 , 109 , 110 , 111 , 111 , 112 , 113 
-.byte  114 , 114 , 115 , 116 , 116 , 117 , 118 , 118 
-.byte  119 , 119 , 120 , 121 , 121 , 122 , 122 , 122 
-.byte  123 , 123 , 124 , 124 , 125 , 125 , 125 , 126 
-.byte  126 , 126 , 126 , 127 , 127 , 127 , 127 , 127 
-.byte  128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 
-.byte  128 , 128 , 128 , 128 , 128 , 128 , 128 , 127 
-.byte  127 , 127 , 127 , 127 , 126 , 126 , 126 , 126 
-.byte  125 , 125 , 125 , 124 , 124 , 123 , 123 , 122 
-.byte  122 , 122 , 121 , 121 , 120 , 119 , 119 , 118 
-.byte  118 , 117 , 116 , 116 , 115 , 114 , 114 , 113 
-.byte  112 , 111 , 111 , 110 , 109 , 108 , 107 , 106 
-.byte  106 , 105 , 104 , 103 , 102 , 101 , 100 , 99 
-.byte  98 , 97 , 96 , 95 , 94 , 93 , 92 , 91 
-.byte  89 , 88 , 87 , 86 , 85 , 84 , 82 , 81 
-.byte  80 , 79 , 78 , 76 , 75 , 74 , 72 , 71 
-.byte  70 , 68 , 67 , 66 , 64 , 63 , 62 , 60 
-.byte  59 , 58 , 56 , 55 , 53 , 52 , 50 , 49 
-.byte  48 , 46 , 45 , 43 , 42 , 40 , 39 , 37 
-.byte  36 , 34 , 33 , 31 , 30 , 28 , 27 , 25 
-.byte  23 , 22 , 20 , 19 , 17 , 16 , 14 , 13 
-.byte  11 , 9 , 8 , 6 , 5 , 3 , 2 , 0 
-.byte -2 ,-3 ,-5 ,-6 ,-8 ,-9 ,-11 ,-13 
-.byte -14 ,-16 ,-17 ,-19 ,-20 ,-22 ,-23 ,-25 
-.byte -27 ,-28 ,-30 ,-31 ,-33 ,-34 ,-36 ,-37 
-.byte -39 ,-40 ,-42 ,-43 ,-45 ,-46 ,-48 ,-49 
-.byte -50 ,-52 ,-53 ,-55 ,-56 ,-58 ,-59 ,-60 
-.byte -62 ,-63 ,-64 ,-66 ,-67 ,-68 ,-70 ,-71 
-.byte -72 ,-74 ,-75 ,-76 ,-78 ,-79 ,-80 ,-81 
-.byte -82 ,-84 ,-85 ,-86 ,-87 ,-88 ,-89 ,-91 
-.byte -92 ,-93 ,-94 ,-95 ,-96 ,-97 ,-98 ,-99 
-.byte -100 ,-101 ,-102 ,-103 ,-104 ,-105 ,-106 ,-106 
-.byte -107 ,-108 ,-109 ,-110 ,-111 ,-111 ,-112 ,-113 
-.byte -114 ,-114 ,-115 ,-116 ,-116 ,-117 ,-118 ,-118 
-.byte -119 ,-119 ,-120 ,-121 ,-121 ,-122 ,-122 ,-122 
-.byte -123 ,-123 ,-124 ,-124 ,-125 ,-125 ,-125 ,-126 
-.byte -126 ,-126 ,-126 ,-127 ,-127 ,-127 ,-127 ,-127 
-.byte -128 ,-128 ,-128 ,-128 ,-128 ,-128 ,-128 ,-128 
-.byte -128 ,-128 ,-128 ,-128 ,-128 ,-128 ,-128 ,-127 
-.byte -127 ,-127 ,-127 ,-127 ,-126 ,-126 ,-126 ,-126 
-.byte -125 ,-125 ,-125 ,-124 ,-124 ,-123 ,-123 ,-122 
-.byte -122 ,-122 ,-121 ,-121 ,-120 ,-119 ,-119 ,-118 
-.byte -118 ,-117 ,-116 ,-116 ,-115 ,-114 ,-114 ,-113 
-.byte -112 ,-111 ,-111 ,-110 ,-109 ,-108 ,-107 ,-106 
-.byte -106 ,-105 ,-104 ,-103 ,-102 ,-101 ,-100 ,-99 
-.byte -98 ,-97 ,-96 ,-95 ,-94 ,-93 ,-92 ,-91 
-.byte -89 ,-88 ,-87 ,-86 ,-85 ,-84 ,-82 ,-81 
-.byte -80 ,-79 ,-78 ,-76 ,-75 ,-74 ,-72 ,-71 
-.byte -70 ,-68 ,-67 ,-66 ,-64 ,-63 ,-62 ,-60 
-.byte -59 ,-58 ,-56 ,-55 ,-53 ,-52 ,-50 ,-49 
-.byte -48 ,-46 ,-45 ,-43 ,-42 ,-40 ,-39 ,-37 
-.byte -36 ,-34 ,-33 ,-31 ,-30 ,-28 ,-27 ,-25 
-.byte -23 ,-22 ,-20 ,-19 ,-17 ,-16 ,-14 ,-13 
-.byte -11 ,-9 ,-8 ,-6 ,-5 ,-3 ,-2 , 0 
-
-
-SinTab2:

+ 0 - 16
snes/loader/routines/songs.asm

@@ -1,16 +0,0 @@
-.Section "SongLUT" superfree
-PtPlayerSongPointertable:
-		.dw Song0
-		.db (:Song0+BaseAdress>>16)
-				
-
-.ends	
-
-.Section "song 0" superfree
-Song0:
-	.dw (Song0End-Song0)
- ;.incbin "data/songs/maf_atomanic_4_hi.bin"
- .incbin "data/songs/maf_tralala_bim_boum_hi.bin"
-
-Song0End:
-.ends

+ 0 - 1152
snes/loader/routines/spcinterface.asm

@@ -1,1152 +0,0 @@
-
-
-SpcHandlerMain:
-	php
-	sep #$20
-;	stz.w $4200			;disable irqs in case we are processing a lengthy spc transfer
-
-;check if spc sends report data
-	lda.w $2141
-	and.b #$e0
-	cmp.b #$e0
-	bne SpcHandlerNoSpcReport
-
-	rep #$31
-	lda.w $2141			;get report type and select corresponding buffer accordingly
-	and.w #7
-	asl a
-	tax
-	lda.w $2142			;get report word and store in buffer
-	sta.l SpcReportBuffer,x
-
-
-SpcHandlerNoSpcReport:
-	rep #$31
-;	sep #$20
-	lda.b SpcHandlerState
-	and.w #$1f			;have 32 states maximum
-	asl a
-	tax
-	jsr (SpcHandlerSubroutineJumpLUT,x)
-	
-	
-	
-	
-	sep #$20
-;	lda.b InterruptEnableFlags	;reenable irqs
-;	sta.w $4200	
-	
-	plp
-	rts
-
-;stops currently playing stream, song, then waits for driver to return to idle state(wait for all scheduled sound effects to play)
-SpcWaitAllCommandsProcessed:
-	php
-	sep #$20
-	stz.w SpcStreamVolume
-	jsr SpcStopSong
-SpcWaitLoop:
-	lda.b SpcCmdFifoStart
-	cmp.b SpcCmdFifoEnd				;check if fifo is empty
-	bne SpcWaitLoop
-	
-	lda.b SpcHandlerState
-	cmp.b #1
-	bne SpcWaitLoop
-	
-	plp
-	rts
-	
-SpcHandlerSubroutineJumpLUT:
-	.dw SpcUploadDriver		;0
-	.dw SpcIdle
-	.dw SpcUploadSong
-	.dw SpcUploadSongWait
-	.dw SpcUploadSampleset
-	.dw SpcUploadSamplesetWait	;5
-	.dw SpcStreamData
-	.dw SpcStreamDataWait
-	.dw SpcPlaySoundeffectUpload	
-	.dw SpcPlaySoundeffectWait
-	.dw SpcStopSongInit		;10
-	.dw SpcStopSongWait 
-	.dw SpcSetSpeedInit
-        .dw SpcSetSpeedWait
-	.dw SpcSetChMaskInit
-        .dw SpcSetChMaskWait		;15
-        .dw SpcSetReportTypeInit
-	.dw SpcSetReportTypeWait
-
-
-
-SpcSetReportTypeInit:
-	rep #$31
-	lda.b SpcHandlerArgument0		;store type and sub-arg
-	sta.w $2141
-	sep #$20
-
-	lda.b #SpcCmdReportType		;exec command
-	sta.w $2140
-	
-	
-	inc.b SpcHandlerState					;goto "wait SE ack"-state
-	rts
-
-SpcSetReportTypeWait:
-	sep #$20
-	lda.w $2140
-	cmp.b #SpcCmdReportType
-	bne SpcSetReportTypeWaitNoIdle			;wait until spc has ack'd the speed change before returning
-
-	lda.b #1
-	sta.b SpcHandlerState					;return to idle once spc has answered
-
-SpcSetReportTypeWaitNoIdle:
-	rts
-
-SpcSetChMaskInit:
-	sep #$20
-	lda.b SpcHandlerArgument0		;store mask
-	sta.w $2141
-
-
-	lda.b #SpcCmdSetSongChMask		;exec command
-	sta.w $2140
-	
-	
-	inc.b SpcHandlerState					;goto "wait SE ack"-state
-	rts
-
-SpcSetChMaskWait:
-	sep #$20
-	lda.w $2140
-	cmp.b #SpcCmdSetSongChMask
-	bne SpcSetChMaskWaitNoIdle			;wait until spc has ack'd the speed change before returing
-
-	lda.b #1
-	sta.b SpcHandlerState					;return to idle once spc has answered
-
-SpcSetChMaskWaitNoIdle:
-	rts
-
-SpcSetSpeedInit:
-	sep #$20
-	lda.b SpcHandlerArgument0		;store speed
-	sta.w $2141
-
-
-	lda.b #SpcCmdSetSongSpeed		;exec command
-	sta.w $2140
-	
-	
-	inc.b SpcHandlerState					;goto "wait SE ack"-state
-	rts
-
-SpcSetSpeedWait:
-	sep #$20
-	lda.w $2140
-	cmp.b #SpcCmdSetSongSpeed
-	bne SpcSetSpeedWaitNoIdle			;wait until spc has ack'd the speed change before returing
-
-	lda.b #1
-	sta.b SpcHandlerState					;return to idle once spc has answered
-	
-
-SpcSetSpeedWaitNoIdle:
-	rts	
-	
-	
-SpcUploadSampleset:
-	sep #$20
-	lda.b #SpcCmdUploadSamplePack					;send "upload song" command
-	sta.w $2140
-	lda.b #5
-	sta.b SpcHandlerState					;goto "wait for spc to ack song upload" state
-	rts
-	
-SpcUploadSamplesetWait:
-	sep #$20
-	lda.w $2140
-	cmp.b #SpcCmdUploadSamplePack					;wait until spc has ack'd upload song command
-	bne SpcUploadSamplePackWaitExit				;else try again next frame
-	
-;	stz.w $4200						;disable irqs
-;upload SamplePack here
-	lda.b SpcHandlerArgument0				;get song number to upload
-	sta.b PtPlayerCurrentSamplePack
-
-	
-	rep #$31				;multiply song number by 3 and use as index into song pointertable
-	and.w #$00ff
-	sta.b PtPlayerDataPointerLo
-	asl a
-	clc
-	adc.b PtPlayerDataPointerLo
-	tax
-
-	lda.l (PtPlayerSamplePackPointertable+BaseAdress),x	;store pointer to song
-	sta.b PtPlayerDataPointerLo
-		
-	lda.l (PtPlayerSamplePackPointertable+$c00001),x
-	
-	sta.b PtPlayerDataPointerHi	
-;	sep #$20
-;	sta.b PtPlayerDataPointerBa
-	
-;	rep #$31
-	ldy.w #$0000
-	lda.b [PtPlayerDataPointerLo],y		;get song length
-	dec a					;substract length word
-	dec a
-	sta.w PtPlayerSmplBufferPosLo
-	iny					;increment source pointer to actual song offset
-	iny
-	sep #$20
-
-SpcUploadSamplePackTransfer1:		
-		lda.b [PtPlayerDataPointerLo],y		;write 3 bytes to ports
-		sta.w $2141
-		iny
-		lda.b [PtPlayerDataPointerLo],y
-		sta.w $2142
-		iny
-		lda.b [PtPlayerDataPointerLo],y
-		sta.w $2143
-		iny
-		
-		lda.b #SpcCmdUploadSongT1		;write ack transfer 1 to port0
-		sta.w $2140
-
-SpcUploadSamplePackTransfer1WaitLoop:				;wait for spc to write transfer 1 ack back
-		cmp.w $2140
-		bne SpcUploadSamplePackTransfer1WaitLoop
-	
-SpcUploadSamplePackTransfer2:		
-		lda.b [PtPlayerDataPointerLo],y		;write 3 bytes to ports
-		sta.w $2141
-		iny
-		lda.b [PtPlayerDataPointerLo],y
-		sta.w $2142
-		iny
-		lda.b [PtPlayerDataPointerLo],y
-		sta.w $2143
-		iny
-		
-		lda.b #SpcCmdUploadSongT2		;write ack transfer 1 to port0
-		sta.w $2140
-
-SpcUploadSamplePackTransfer2WaitLoop:				;wait for spc to write transfer 1 ack back
-		cmp.w $2140
-		bne SpcUploadSamplePackTransfer2WaitLoop
-	
-		cpy.w PtPlayerSmplBufferPosLo		;check if transfer length is exceeded
-		bcc SpcUploadSamplePackTransfer1
-		
-		lda.b #SpcCmdUploadSamplePackDone		;send "upload song complete" commadn if transfer is done
-		sta.w $2140
-	
-		lda.b #1
-		sta.b SpcHandlerState					;return to idle
-
-;		lda.b InterruptEnableFlags	;reenable irqs
-;		sta.w $4200
-
-SpcUploadSamplePackWaitExit:
-	lda.b SpcUploadedFlag
-	ora.b #$40						;set sample pack uploaded flag.
-	sta.b SpcUploadedFlag
-
-	rts	
-
-
-SpcStopSongInit:
-	rep #$31
-	stz.w $2141
-	stz.w $2142
-	sep #$20
-	lda.b #SpcCmdStopSong		;exec command
-	sta.w $2140	
-	inc.b SpcHandlerState		;goto "wait SE ack"-state
-	rts
-
-SpcStopSongWait:	
-	sep #$20
-	lda.w $2140
-	cmp.b #SpcCmdStopSong
-	bne SpcStopSongWaitNoIdle			;wait until spc has ack'd the song/stream stop before returing
-
-	lda.b #1
-	sta.b SpcHandlerState					;return to idle once spc has answered
-	
-
-SpcStopSongWaitNoIdle:
-	rts
-
-
-
-SpcPlaySoundeffectUpload:
-	rep #$31
-	lda.b SpcHandlerArgument0		;store arguments
-	sta.w $2141
-	lda.b SpcHandlerArgument1
-	and.w #$7fff				;mask off msb and use as wurst
-	ora.w SpcSoundEffectFlipFlag
-	sta.w $2142
-	lda.w SpcSoundEffectFlipFlag
-	eor.w #$8000
-	sta.w SpcSoundEffectFlipFlag
-	sep #$20
-	lda.b #SpcCmdPlaySoundEffect		;exec command
-	sta.w $2140
-	
-	
-;	lda.b #1
-;	sta.b SpcHandlerState					;don't wait
-	inc.b SpcHandlerState					;goto "wait SE ack"-state
-	rts
-
-;dont use this cause it sometimes plays a sound effect twice
-SpcPlaySoundeffectWait:	
-	sep #$20
-	lda.w $2140
-	cmp.b #SpcCmdPlaySoundEffect
-	bne SpcPlaySoundeffectWaitNoIdle			;wait until spc has ack'd the soundeffect before returing
-
-	lda.b #1
-	sta.b SpcHandlerState					;return to idle once spc has answered
-	
-
-SpcPlaySoundeffectWaitNoIdle:
-	rts
-	
-		
-SpcUploadDriver:
-		sep #$20
-;		stz.w $4200
-		lda.b #(:PtplayerSpcCode+BaseAdress>>16)
-		ldx.w #PtplayerSpcCode
-		sta.b PtPlayerDataPointerBa
-		stx.b PtPlayerDataPointerLo
-;		jsr PtPlayerInit
-;		php
-;		sep #$20
-;		stz.w $4200
-		REP #$31
-		LDY.w #$0000				;clear data pointer
-		LDA.w #$BBAA
-
-PtPlayerInitSpcWaitLoop1:		
-		CMP.w $2140				;wait for spc to respond
-		BNE PtPlayerInitSpcWaitLoop1
-
-		SEP #$20
-		LDA.b #$CC				;send "start transfer"
-		BRA PtPlayerInitDoTransfer
-
-PtPlayerInitGetByte:
-		LDA.b [PtPlayerDataPointerLo],y
-		INY
-		XBA
-		LDA.b #$00
-		BRA PtPlayerInitClearSpcPort0
-
-PtPlayerInitGetNextByte:
-		XBA
-		LDA.b [PtPlayerDataPointerLo],y
-		INY
-		XBA
-
-PtPlayerInitSpcWaitLoop2:
-		CMP.w $2140
-		BNE PtPlayerInitSpcWaitLoop2
-		INC A
-PtPlayerInitClearSpcPort0:
-		REP #$20
-		STA.w $2140
-		SEP #$20
-		DEX
-		BNE PtPlayerInitGetNextByte
-
-PtPlayerInitSpcWaitLoop3:
-		CMP.w $2140
-		BNE PtPlayerInitSpcWaitLoop3
-
-PtPlayerInitAddLoop:
-		ADC.b #$03
-		BEQ PtPlayerInitAddLoop
-
-
-PtPlayerInitDoTransfer:
-		PHA
-		REP #$20
-		LDA.b [PtPlayerDataPointerLo],y
-		INY
-		INY
-		TAX
-		LDA.b [PtPlayerDataPointerLo],y
-		INY
-		INY
-		STA.w $2142
-		SEP #$20
-		CPX.w #$0001				;whats this?
-		LDA.b #$00
-		ROL A
-		STA.w $2141
-		ADC.b #$7F
-		PLA
-		STA.w $2140
-		cpx.w #$0001				;fix to be able to upload apucode during active nmi
-		bcc PtPlayerInitDone
-
-PtPlayerInitSpcWaitLoop4:
-		CMP.w $2140
-		BNE PtPlayerInitSpcWaitLoop4
-
-
-		BVS PtPlayerInitGetByte
-
-PtPlayerInitDone:
-		SEP #$20
-;		lda.b #%10000001
-;		sta.w $4200
-
-/*
-		lda.b #$7f				;init some variables
-		sta.b PtPlayerMainVolL
-		sta.b PtPlayerMainVolR
-		lda.b #%00001111
-		sta.b PtPlayerChannelEnable
-		lda.b #$00
-		sta.b PtPlayerEchoVolL
-		sta.b PtPlayerEchoVolR
-		sta.b PtPlayerChannelEchoEnable
-		lda.b #$01
-		sta.b CGIntroPlaySongNumber
-*/		
-;		PLP
-		lda.b InterruptEnableFlags	;reenable irqs
-;		sta.w $4200
-		inc.b SpcHandlerState			;go to idle state
-
-;init some variables
-	lda.b #$a0
-	sta.w SpcSongSpeed			;set speed to default
-	lda.b #$0f
-	sta.w SpcSongChMask			;set song channel mask to default
-		jsr ClearSpcReportBuffer
-		
-		RTS	
-	
-ClearSpcReportBuffer:
-	php
-	rep #$31
-	lda.w #$0000			;clear with y-position at line 255
-	ldx.w #16
-ClearSpcReportBufferLoop:
-	sta.l (SpcReportBuffer &$ffff + $7e0000-2),x
-	dex
-	dex
-	bne ClearSpcReportBufferLoop
-	plp
-	rts	
-		
-;check if there's a new command in the fifo, else return
-;fifo buffer organization is:
-;each entry: 1 command byte, 3 argument bytes
-;fifo has 16 entries/64bytes total
-SpcIdle:
-	sep #$20
-	stz.w $2140					;clear port0
-	
-	lda.b SpcCmdFifoStart
-	cmp.b SpcCmdFifoEnd				;check if fifo is empty
-	beq SpcIdleFifoEmpty
-	
-;theres a spc command present:
-
-	rep #$31
-	and.w #$3f					;limit fifo pointer to 64 bytes
-	tax						
-	lda.w SpcCmdFifo,x				;get command
-	
-	sta.b SpcHandlerState					;store command/state and argument 1
-	
-	lda.w SpcCmdFifo+2,x				;get command
-	
-	sta.b SpcHandlerArgument1				;store arguments 1 and 2
-
-	lda.b SpcHandlerState				;directly execute fetched command
-	and.w #$1f					;except when its an idle command
-	cmp.w #1					;because this would allow for unlimited nesting and possibly stack overflow
-	beq SpcIdleFifoEmpty
-	
-	asl a
-	tax
-	jsr (SpcHandlerSubroutineJumpLUT,x)
-	
-	sep #$20
-	lda.b SpcCmdFifoStart				;goto next fifo entry next frame
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoStart	
-	
-SpcIdleFifoEmpty:
-	rts
-	
-SpcUploadSong:
-	sep #$20
-
-	lda.b #SpcCmdUploadSong					;send "upload song" command
-	sta.w $2140
-	lda.b #3
-	sta.b SpcHandlerState					;goto "wait for spc to ack song upload" state
-	rts
-	
-SpcUploadSongWait:
-	sep #$20
-	lda.w $2140
-	cmp.b #SpcCmdUploadSong					;wait until spc has ack'd upload song command
-	bne SpcUploadSongWaitExit				;else try again next frame
-	
-	
-;upload song here
-;	stz.w $4200
-	lda.b SpcHandlerArgument0				;get song number to upload
-	sta.b PtPlayerCurrentSong
-
-	
-	rep #$31				;multiply song number by 3 and use as index into song pointertable
-	and.w #$00ff
-	sta.b PtPlayerDataPointerLo
-	asl a
-	clc
-	adc.b PtPlayerDataPointerLo
-	tax
-
-	lda.l (PtPlayerSongPointertable+BaseAdress),x	;store pointer to song
-	sta.b PtPlayerDataPointerLo
-		
-	lda.l (PtPlayerSongPointertable+$c00001),x
-	
-	sta.b PtPlayerDataPointerHi	
-;	sep #$20
-;	sta.b PtPlayerDataPointerBa
-	
-;	rep #$31
-	ldy.w #$0000
-	lda.b [PtPlayerDataPointerLo],y		;get song length
-	dec a					;substract length word
-	dec a
-	sta.w PtPlayerSmplBufferPosLo
-	iny					;increment source pointer to actual song offset
-	iny
-	sep #$20
-
-SpcUploadSongTransfer1:		
-		lda.b [PtPlayerDataPointerLo],y		;write 3 bytes to ports
-		sta.w $2141
-		iny
-		lda.b [PtPlayerDataPointerLo],y
-		sta.w $2142
-		iny
-		lda.b [PtPlayerDataPointerLo],y
-		sta.w $2143
-		iny
-		
-		lda.b #SpcCmdUploadSongT1		;write ack transfer 1 to port0
-		sta.w $2140
-
-SpcUploadSongTransfer1WaitLoop:				;wait for spc to write transfer 1 ack back
-		cmp.w $2140
-		bne SpcUploadSongTransfer1WaitLoop
-	
-SpcUploadSongTransfer2:		
-		lda.b [PtPlayerDataPointerLo],y		;write 3 bytes to ports
-		sta.w $2141
-		iny
-		lda.b [PtPlayerDataPointerLo],y
-		sta.w $2142
-		iny
-		lda.b [PtPlayerDataPointerLo],y
-		sta.w $2143
-		iny
-		
-		lda.b #SpcCmdUploadSongT2		;write ack transfer 1 to port0
-		sta.w $2140
-
-SpcUploadSongTransfer2WaitLoop:				;wait for spc to write transfer 1 ack back
-		cmp.w $2140
-		bne SpcUploadSongTransfer2WaitLoop
-	
-		cpy.w PtPlayerSmplBufferPosLo		;check if transfer length is exceeded
-		bcc SpcUploadSongTransfer1
-		
-		lda.b #SpcCmdUploadSongDone		;send "upload song complete" commadn if transfer is done
-		sta.w $2140
-	
-		lda.b #1
-		sta.b SpcHandlerState					;return to idle
-
-		lda.b InterruptEnableFlags	;reenable irqs
-;		sta.w $4200
-
-SpcUploadSongWaitExit:
-	lda.b SpcUploadedFlag
-	ora.b #$80						;set song uploaded flag.
-	sta.b SpcUploadedFlag
-
-	rts	
-
-;stops currently playing song/stream
-SpcStopSong:
-	php
-	rep #$31
-	lda.b SpcCmdFifoEnd			;get current position in spc command fifo buffer		
-	and.w #$ff
-	tax	
-	sep #$20
-;	sta.w (SpcCmdFifo+1),x
-	lda.b #SpcFifoCmdStopSong
-	sta.w SpcCmdFifo,x
-	
-	lda.b SpcCmdFifoEnd
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoEnd
-	plp
-	rts
-
-;in:	a,8bit: SE number to play
-;	x,16bit: volume & pitch low byte: pitch(use default if zero, multiplied by 16). high byte: volume(use default if zero) bit7:sign, bits6-4:panning, bits 3-0:volume(multiplied with $10)	
-SpcPlaySoundEffect:
-	php
-	rep #$31
-	pha					;push SE number
-	phx					;push arguments
-	lda.b SpcCmdFifoEnd			;get current position in spc command fifo buffer		
-	and.w #$ff
-	tax
-	pla					;get arguments
-	sta.w (SpcCmdFifo+2),x			;store in fifo arguments 2,3
-	
-	pla					;fetch song number again
-	sep #$20
-	sta.w (SpcCmdFifo+1),x
-	lda.b #SpcFifoCmdPlaySE
-	sta.w SpcCmdFifo,x
-	
-	lda.b SpcCmdFifoEnd
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoEnd
-	plp
-	rts
-
-;same as above, but doesn't use x as input
-SpcPlaySoundEffectSimple:
-	php
-	rep #$31
-	phx					;push arguments
-	pha					;push SE number
-
-	lda.b SpcCmdFifoEnd			;get current position in spc command fifo buffer		
-	and.w #$ff
-	tax
-	lda.w #0
-	sta.w (SpcCmdFifo+2),x			;store in fifo arguments 2,3
-	
-	pla					;fetch song number again
-	sep #$20
-	sta.w (SpcCmdFifo+1),x
-	lda.b #SpcFifoCmdPlaySE
-	sta.w SpcCmdFifo,x
-	
-	lda.b SpcCmdFifoEnd
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoEnd
-	plx
-	plp
-	rts
-
-
-;in: a,8bit: song number to play
-SpcPlaySong:
-	php
-	rep #$31
-	pha					;push song number
-	lda.b SpcCmdFifoEnd			;get current position in spc command fifo buffer		
-	and.w #$ff
-	tax
-	
-	pla					;fetch song number again
-	sep #$20
-	sta.w (SpcCmdFifo+1),x
-	lda.b #SpcFifoCmdUploadSong
-	sta.w SpcCmdFifo,x
-	
-	lda.b SpcCmdFifoEnd
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoEnd
-	
-	stz.w SpcStreamVolume			;mute eventually playing stream, stop stream
-	
-	lda.b SpcUploadedFlag
-	and.b #$7f						;clear song uploaded flag. will be set once song upload has been completed later on
-	sta.b SpcUploadedFlag
-;	lda.b SpcCurrentStreamSet		;useful, but messes up if sampleset + song dont fit into spc ram
-;	jsr SpcIssueSamplePackUpload
-	plp
-	rts
-
-;in: a,8bit: streamset number to play
-SpcPlayStream:
-	php
-	sep #$20
-	pha
-	rep #$31
-	stz.w SpcStreamFrame
-	lda.b SpcCmdFifoEnd			;get current position in spc command fifo buffer		
-	and.w #$ff
-	tax
-	
-	sep #$20
-	pla					;store frameset number
-	sta.w (SpcCmdFifo+1),x
-	lda.b #SpcFifoCmdStreamBrr
-	sta.w SpcCmdFifo,x
-	
-	lda.b SpcCmdFifoEnd
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoEnd
-
-	sep #$20
-	stz.w SpcStreamVolume			;mute eventually playing stream, stop stream
-	plp
-	rts
-	
-	
-;in: a,8bit: sample pack number to upload
-SpcIssueSamplePackUpload:
-	php
-	rep #$31
-	pha					;push song number
-	lda.b SpcCmdFifoEnd			;get current position in spc command fifo buffer		
-	and.w #$ff
-	tax
-	
-	pla					;fetch song number again
-	sep #$20
-	sta.w (SpcCmdFifo+1),x
-	lda.b #SpcFifoCmdUploadSamplePack
-	sta.w SpcCmdFifo,x
-	
-	lda.b SpcCmdFifoEnd
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoEnd
-
-	lda.b SpcUploadedFlag
-	and.b #$bf						;clear sample pack uploaded flag. will be set once song upload has been completed later on
-	sta.b SpcUploadedFlag
-	
-	plp
-	rts
-
-SpcStreamData:
-	sep #$20
-	lda.b #$7f				;turn on streaming volume
-	sta.w SpcStreamVolume
-	
-	lda.b SpcHandlerArgument0		;get frameset number to stream
-	sta.b SpcCurrentStreamSet		;multiply by 5 to get pointer into frameset table			
-	rep #$31
-	and.w #$ff
-	sta.b SpcTempBuffer
-	asl a
-	asl a
-	clc
-	adc.b SpcTempBuffer
-	
-	tax
-	lda.l (StreamSetLut+BaseAdress+3),x	;get number of frames for this set
-	sta.w $2141				;write number of frames to stream to spc
-	
-				
-	sep #$20	
-	lda.b #SpcCmdReceiveStream				;send "upload song" command
-	sta.w $2140
-
-	lda.l $2140
-	cmp.b #SpcCmdReceiveStreamComplete			;don't switch to streamer yet if spc is still finishing the last transfer.(only applicable if last command was streaming)
-	beq SpcStreamDataWaitSpcLastStream
-	
-	lda.b #7
-	sta.b SpcHandlerState					;goto "wait for spc to ack song upload" state
-	
-SpcStreamDataWaitSpcLastStream:	
-	rts
-
-
-SpcStreamDataReturnIdle:
-	sep #$20
-	lda.b HdmaFlags
-	and.b #$7f					;disable spc stream on hdma channel 7
-	sta.b HdmaFlags	
-	lda.b #1						;return to idle if spc signalizes that transfer is complete
-	sta.b SpcHandlerState
-SpcStreamDataExit:
-	rts
-
-	
-SpcStreamDataWait:
-	sep #$20
-	lda.w $2140
-	cmp.b #SpcCmdReceiveStreamComplete			;check if transfer complete
-	beq SpcStreamDataReturnIdle
-	cmp.b #SpcCmdReceiveStream				;wait until spc has ack'd upload song command
-	bne SpcStreamDataExit					;else try again next frame	
-
-	
-	
-	lda.b SpcCurrentStreamSet				;get current frameset number
-	rep #$31
-	and.w #$ff
-	sta.b SpcTempBuffer					;multiply by 5
-	asl a
-	asl a
-	clc
-	adc.b SpcTempBuffer
-	
-	tax
-	lda.l (StreamSetLut+BaseAdress),x				;store offset of first frame in set
-	sta.b SpcTempBuffer+2
-	lda.l (StreamSetLut+BaseAdress+1),x
-	sta.b SpcTempBuffer+3
-	
-	lda.w $2141						;get frame request number
-									;multiply with 144, get pointer to requested frame. warning: one bank holds $1c7 frames, or $fff0 bytes of data. must wrap to next bank if bigger.
-	sta.b SpcTempBuffer+5					;store frame request number
-	sta.w SpcStreamFrame
-	pha
-	lda.w SpcStreamVolume			;only write current frame if stream hasnt been stopped. otherwise external routines might be confused when transitioning between streams
-	and.w #$ff
-	bne DontClearSpcStreamFrame
-	
-	stz.w SpcStreamFrame
-
-	
-DontClearSpcStreamFrame:
-	pla
-
-SpcStreamCalcFrameOffsetLoop:
-	cmp.w #SpcFramesPerBank					;check if number of frames exceeds bank limit
-	bcc SpcStreamCalcFrameOffsetNoBankWrap
-
-	sep #$20						;if it does, increase bank
-	inc.b SpcTempBuffer+4
-	rep #$31						;and substract one bank full of samples from total amount
-	sec
-	sbc.w #SpcFramesPerBank
-	bra SpcStreamCalcFrameOffsetLoop			;do this until we're in the bank the frame actually is in
-
-SpcStreamCalcFrameOffsetNoBankWrap:
-	
-	asl a							;multiply by 144
-	asl a
-	asl a
-	asl a							;first multiply by 16
-	sta.b SpcTempBuffer+2
-	
-	asl a							;then by 128
-	asl a
-	asl a
-	
-	clc
-	adc.b SpcTempBuffer+2					;this is x*144
-	sta.b SpcTempBuffer+2					;and save in pointer
-
-;line 1, command
-	lda.w #36/2
-	sta.b SpcTempBuffer					;set scanline counter
-	lda.w #SpcScanlineWaitCount						;store 1 in frame count
-	ldx.w #0						;clear hdma table pointer
-	txy							;clear brr source counter
-	
-	sta.l HdmaSpcBuffer,x
-
-	lda.w #SpcCmdSubmitStreamNumber				;send "submit frame #"-cmd
-	sta.l HdmaSpcBuffer+1,x
-	
-	lda.b SpcTempBuffer+5					;get frame submit number
-	sta.l HdmaSpcBuffer+2,x
-
-	lda.w SpcStreamVolume
-	sta.l HdmaSpcBuffer+4,x					;store volume
-	
-	inx
-	inx
-	inx
-	inx
-	inx
-;line 2, waitloop &  frame transmit
-SpcStreamSetupHdmaTableLoop:
-	lda.w #1
-	sta.l HdmaSpcBuffer,x				;one line
-	
-	lda.b [SpcTempBuffer+2],y				;brr data to ports $2140-$2143
-	sta.l HdmaSpcBuffer+1,x
-
-	iny
-	iny
-	
-	lda.b [SpcTempBuffer+2],y
-	sta.l HdmaSpcBuffer+3,x
-
-	inx
-	inx
-	inx
-	inx
-	inx
-	
-;	iny
-;	iny
-	iny
-	iny
-
-	lda.w #1
-	sta.l HdmaSpcBuffer,x				;one line
-	
-	lda.b [SpcTempBuffer+2],y				;brr data to ports $2140-$2143
-	sta.l HdmaSpcBuffer+1,x
-
-	iny
-	iny
-	
-	lda.b [SpcTempBuffer+2],y
-	sta.l HdmaSpcBuffer+3,x
-
-	inx
-	inx
-	inx
-	inx
-	inx
-	
-;	iny
-;	iny
-	iny
-	iny	
-	dec.b SpcTempBuffer
-	bne SpcStreamSetupHdmaTableLoop
-
-;this doesnt work right. reason is that the the stream data sometimes contains "false" commands.
-;write spc command here: (only play soundeffect, stop song/stream is allowed here)
-
-	stz.b SpcTempBuffer				;clear spc command field
-	stz.b SpcTempBuffer+2
-/*
-	
-	lda.b SpcCmdFifoStart
-	cmp.b SpcCmdFifoEnd				;check if fifo is empty
-	beq SpcStreamFifoEmpty
-	
-;theres a spc command present:
-	rep #$31
-	and.w #$3f					;limit fifo pointer to 64 bytes
-	tax						
-	lda.w SpcCmdFifo,x				;get command
-	and.w #$ff
-	cmp.w #SpcCmdPlaySoundEffect
-	beq SpcStreamFifoExecCmd
-	cmp.w #SpcCmdStopSong
-	beq SpcStreamFifoExecCmdExit
-	
-	bra SpcStreamFifoEmpty
-
-SpcStreamFifoExecCmdExit:
-	sep #$20
-	lda.b #1
-	sta.b SpcHandlerState				;if stop command is present in fifo, immediately halt streamer and return to idle state. next frame, fifo command handler will process the stop command normally.
-	rts
-
-SpcStreamFifoExecCmd:	
-
-;state
-	lda.w SpcCmdFifo,x				;get command
-	sta.b TempBuffer				;store command/state and argument 1
-	
-	lda.w SpcCmdFifo+2,x				;get command
-	
-	sta.b TempBuffer+2				;store arguments 1 and 2
-
-	
-	sep #$20
-	lda.b SpcCmdFifoStart				;goto next fifo entry next frame
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoStart	
-	
-SpcStreamFifoEmpty:
-	rep #$31
-*/
-	lda.w #1
-	sta.l HdmaSpcBuffer,x				;one line
-	
-
-	lda.b SpcTempBuffer
-	sta.l HdmaSpcBuffer+1,x				
-
-	
-	lda.b SpcTempBuffer+2
-	sta.l HdmaSpcBuffer+3,x
-
-	inx
-	inx
-	inx
-	inx
-	inx
-
-;terminate hdma table:	
-	lda.w #0
-	sta.l HdmaSpcBuffer,x
-	
-	lda.w #HdmaSpcBuffer & $ffff
-	sta.l $4372					;hdma source offset
-	
-	sep #$20
-	lda.b HdmaFlags
-	ora.b #$80					;enable spc stream on hdma channel 7
-	sta.b HdmaFlags
-	
-	lda.b #$7e					;hdma source bank
-	sta.l $4374
-	
-	lda.b #%00000100				;hdma config, direct, 4 regs write once
-	sta.l $4370
-	
-	lda.b #$40					;bbus target, apu port $2140-$2143
-	sta.l $4371
-	
-	rts
-	
-;in: SpcSongSpeed,8bit: song speed(timer duration. default is #$a0. lower=faster, higher=slower
-SpcSetSongSpeed:
-	php
-	rep #$31
-;	pha					;push speed
-	lda.b SpcCmdFifoEnd			;get current position in spc command fifo buffer		
-	and.w #$ff
-	tax
-	
-;	pla					;fetch speed again
-	sep #$20
-	lda.w SpcSongSpeed
-	sta.w (SpcCmdFifo+1),x
-	lda.b #SpcFifoCmdSetSpeed
-	sta.w SpcCmdFifo,x
-	
-	lda.b SpcCmdFifoEnd
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoEnd
-	
-;	stz.w SpcStreamVolume			;mute eventually playing stream, stop stream
-	
-;	lda.b SpcCurrentStreamSet		;useful, but messes up if sampleset + song dont fit into spc ram
-;	jsr SpcIssueSamplePackUpload
-	plp
-	rts
-
-;in: SpcSongSpeed,8bit: song speed(timer duration. default is #$a0. lower=faster, higher=slower
-SpcSetSongChannelMask:
-	php
-	rep #$31
-	lda.b SpcCmdFifoEnd			;get current position in spc command fifo buffer		
-	and.w #$ff
-	tax
-	
-	sep #$20
-	lda.w SpcSongChMask
-	sta.w (SpcCmdFifo+1),x
-	lda.b #SpcFifoCmdSetChMask
-	sta.w SpcCmdFifo,x
-	
-	lda.b SpcCmdFifoEnd
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoEnd
-	
-	plp
-	rts
-
-;input: SpcReportType,8bit: 0=none 1=timecode 2=channel-levels(vol out) 3=special mod command (mod command $e0. this is "set filter", unused in almost any player
-SpcSetReportType:
-	php
-	rep #$31
-	lda.b SpcCmdFifoEnd			;get current position in spc command fifo buffer		
-	and.w #$ff
-	tax
-	
-	sep #$20
-	lda.w SpcReportType
-	and.b #$07				;8 types max
-	sta.w (SpcCmdFifo+1),x
-	lda.b #SpcFifoCmdSetReportType
-	sta.w SpcCmdFifo,x
-	
-	lda.b SpcCmdFifoEnd
-	clc
-	adc.b #4
-	and.b #$3f				;16x4byte entries maximum 
-	sta.b SpcCmdFifoEnd
-	
-	plp
-	rts
-	
-;legacy code:
-PtPlayerInit:
-PtPlayerMainHandler:
-PtPlayerUploadVolEcho:
-	rts
-	
-;plays sound effect with panning set to current objects x-position
-SpcPlaySoundEffectObjectXPos:
-	php
-
-	rep #$31
-	pha
-	ldx.b ObjectListPointerCurrent
-	lda.w ObjEntryXPos,x				;get upper 4 nibbles of x-pos
-	lsr a												;remove subpixel prec
-	lsr a
-	lsr a
-	lsr a
-	
-	lsr a						;use bits 6-4 for panning
-	and.w #$7f					;clear sign
-	ora.w #$0F					;set max volume
-	xba
-	tax
-	pla
-	sep #$20
-
-	jsr SpcPlaySoundEffect	
-	
-	
-	
-	plp
-	rts
-		
-

+ 0 - 28
snes/loader/routines/spritedata.asm

@@ -1,28 +0,0 @@
-.Section "sprite data" superfree
-;24bit pointers to sprite tilesets + 16bit length
-SpriteTilesetLUT:
-	.dw SpriteTileset0
-	.db :SpriteTileset0+$c0
-
-			
-;16bit pointers to sprite palettes + 16bit length
-SpritePaletteLUT:	
-	.dw SpritePalette0-SpritePaletteLUT
-	.dw (SpritePalette0End-SpritePalette0)
-		
-		
-SpritePalette0:
-	;.incbin "data/cpuusage.clr" READ 32
-    .db 0
-SpritePalette0End:
-
-
-.ends
-
-
-
-.Section "spritetileset 0" superfree
-SpriteTileset0:
-	;.incbin "data/cpuusage.pic"	
-    .db 0
-.ends

+ 0 - 648
snes/loader/routines/textstrings.asm

@@ -1,648 +0,0 @@
-/*
-normal ASCII chars. $e0-$ff is reserved for special characters (countries etc)
-
-text byte commands:
-
-#$00 - terminate string
-#$01 - set new offset, only executed if not first byte in string(has 2 additional bytes)
-#$02 - set font
-#$03 - draw string from special adress, but with fixed length(has 4 additional bytes, first byte length, last 3 bytes string vector, maximum string length: 32 letters)
-#$04 - draw string from special adress(has 3 additional bytes for string vector)
-#$05 - draw byte in hexadecimal(has 3 additional bytes for string vector)
-#$06 - draw byte in binary(has 3 additional bytes for string vector)
-#$07 - change palette number(AND'ed with 0x7)
-#$08 - draw byte in decimal
-#$09 - set snes mood
-
-
-rows:
-
-line 00: 0x0000
-line 01: 0x0040
-line 02: 0x0080
-line 03: 0x00C0
-line 04: 0x0100
-line 05: 0x0140
-line 06: 0x0180
-line 07: 0x01c0
-line 08: 0x0200
-line 09: 0x0240
-line 10: 0x0280
-line 11: 0x02c0
-line 12: 0x0300
-line 13: 0x0340
-line 14: 0x0380
-line 15: 0x03c0
-line 16: 0x0400
-line 17: 0x0440
-line 18: 0x0480
-line 19: 0x04c0
-line 20: 0x0500
-line 21: 0x0540
-line 22: 0x0580
-line 23: 0x05c0
-line 24: 0x0600
-line 25: 0x0640
-line 26: 0x0680
-line 27: 0x06c0
-*/
-
-.Section "TextstringLUT" superfree	
-TextStringPTable:	
-	.dw TextString0
-	.dw TextString1
-	.dw TextString2
-	.dw TextString3
-	.dw TextString4
-	.dw TextString5
-	.dw TextString6
-	.dw TextString7
-	.dw TextString8
-	.dw TextString9
-
-	.dw TextString10
-	.dw TextString11
-	.dw TextString12
-	.dw TextString13
-	.dw TextString14
-	.dw TextString15
-	.dw TextString16
-	.dw TextString17
-	.dw TextString18
-	.dw TextString19
-
-	.dw TextString20
-	.dw TextString21
-	.dw TextString22
-	.dw TextString23
-	.dw TextString24
-	.dw TextString25
-	.dw TextString26
-	.dw TextString27
-	.dw TextString28
-	.dw TextString29
-
-	.dw TextString30
-	.dw TextString31
-	.dw TextString32
-	.dw TextString33
-	.dw TextString34
-	.dw TextString35
-	.dw TextString36
-	.dw TextString37
-	.dw TextString38
-	.dw TextString39
-
-	.dw TextString40
-	.dw TextString41
-	.dw TextString42
-	.dw TextString43
-	.dw TextString44
-	.dw TextString45
-	.dw TextString46
-	.dw TextString47
-	.dw TextString48
-	.dw TextString49
-
-	.dw TextString50
-	.dw TextString51
-	.dw TextString52
-	.dw TextString53
-	.dw TextString54
-	.dw TextString55
-	.dw TextString56
-	.dw TextString57
-	.dw TextString58
-	.dw TextString59
-
-	.dw TextString60
-	.dw TextString61
-	.dw TextString62
-	.dw TextString63
-	.dw TextString64
-	.dw TextString65
-	.dw TextString66
-	.dw TextString67
-	.dw TextString68
-	.dw TextString69
-
-	.dw TextString70
-	.dw TextString71
-	.dw TextString72
-	.dw TextString73
-	.dw TextString74
-	.dw TextString75
-	.dw TextString76
-	.dw TextString77
-	.dw TextString78
-	.dw TextString79
-
-	.dw TextString80
-	.dw TextString81
-	.dw TextString82
-	.dw TextString83
-	.dw TextString84
-	.dw TextString85
-	.dw TextString86
-	.dw TextString87
-	.dw TextString88
-	.dw TextString89
-
-	.dw TextString90
-	.dw TextString91
-	.dw TextString92
-	.dw TextString93
-	.dw TextString94
-	.dw TextString95
-	.dw TextString96
-	.dw TextString97
-	.dw TextString98
-	.dw TextString99
-	
-	.dw TextString100
-	.dw TextString101
-	.dw TextString102
-	.dw TextString103
-	.dw TextString104
-	.dw TextString105
-	.dw TextString106
-	.dw TextString107
-	.dw TextString108
-	.dw TextString109
-
-	.dw TextString110
-	.dw TextString111
-	.dw TextString112
-	.dw TextString113
-	.dw TextString114
-	.dw TextString115
-	.dw TextString116
-	.dw TextString117
-	.dw TextString118
-	.dw TextString119
-
-	.dw TextString120
-	.dw TextString121
-	.dw TextString122
-	.dw TextString123
-	.dw TextString124
-	.dw TextString125
-	.dw TextString126
-	.dw TextString127
-	.dw TextString128
-	.dw TextString129
-
-	.dw TextString130
-	.dw TextString131
-	.dw TextString132
-	.dw TextString133
-	.dw TextString134
-	.dw TextString135
-	.dw TextString136
-	.dw TextString137
-	.dw TextString138
-	.dw TextString139
-
-	.dw TextString140
-	.dw TextString141
-	.dw TextString142
-	.dw TextString143
-	.dw TextString144
-	.dw TextString145
-	.dw TextString146
-	.dw TextString147
-	.dw TextString148
-	.dw TextString149
-
-	.dw TextString150
-	.dw TextString151
-	.dw TextString152
-	.dw TextString153
-	.dw TextString154
-	.dw TextString155
-	.dw TextString156
-	.dw TextString157
-	.dw TextString158
-	.dw TextString159
-
-	.dw TextString160
-	.dw TextString161
-	.dw TextString162
-	.dw TextString163
-	.dw TextString164
-	.dw TextString165
-	.dw TextString166
-	.dw TextString167
-	.dw TextString168
-	.dw TextString169
-
-	.dw TextString170
-	.dw TextString171
-	.dw TextString172
-	.dw TextString173
-	.dw TextString174
-	.dw TextString175
-	.dw TextString176
-	.dw TextString177
-	.dw TextString178
-	.dw TextString179
-	
-	.dw TextString180
-	.dw TextString181
-	.dw TextString182
-	.dw TextString183
-	.dw TextString184
-	.dw TextString185
-	.dw TextString186
-	
-.ends	
-
-.Section "text strings" superfree
-
-
-
-
-
-TextStrings:
-
-
-TextString0:
-	.dw $004c
-
-	.db "- OPTIXX test -"			;textstring
-
-	.db 1
-	.dw $00d0
-	.db "Debug: Main"
-	.db $00					;terminator
-	
-TextString1:
-	.dw $0146
-	.db "Video IRQs:"			;textstring
-	.db 1
-	.dw $0146+11*2
-	.db 5
-	.dw VIrqCounter
-	.db $7e
-	.db $00
-
-;this is the textstring for the text buffer of the menu system
-TextString2:
-	.dw $0000				;offset on bg1 tilemap
-	.db $04					;terminator
-	.dw (LoadMenuStringBuffer&$ffff)
-	.db $7e
-TextString3:
-	.dw $004c
-
-	.db "- OPTIXX test -"			;textstring
-
-	.db 1
-	.dw $00d0
-	.db "Debug: Audio"
-	.db $00	
-TextString4:
-	.dw $0186
-	.db "EXT IRQs:"			;textstring
-	.db 1
-	.dw $0186+11*2
-	.db 5
-	.dw ExtIrqCounter
-	.db $7e
-	.db $00
-TextString5:
-	.dw $01c6
-	.db "$00:3000"			;textstring
-	.db 1
-	.dw $01c6+11*2
-	.db 5
-	.dw $3000
-	.db $00
-	.db $00
-TextString6:
-	.dw $0186+$e
-	.db 5
-	.dw JoyPortBuffer&$ffff+1
-	.db $7e
-	.db 0	
-TextString7:
-	.dw $01c6
-	.db "Joy2:"
-	.db 5
-	.dw JoyPortBuffer&$ffff+2
-	.db $7e
-	.db 0
-TextString8:
-	.dw $01c6+$e
-	.db 5
-	.dw JoyPortBuffer&$ffff+3
-	.db $7e
-	.db 0	
-TextString9:
-	.dw $0206
-	.db "Joy3:"
-	.db 5
-	.dw JoyPortBuffer&$ffff+4
-	.db $7e
-	.db 0
-TextString10:
-	.dw $0206+$e
-	.db 5
-	.dw JoyPortBuffer&$ffff+5
-	.db $7e
-	.db 0	
-TextString11:
-	.dw $0246
-	.db "Joy4:"
-	.db 5
-	.dw JoyPortBuffer&$ffff+6
-	.db $7e
-	.db 0
-TextString12:
-	.dw $0246+$e
-	.db 5
-	.dw JoyPortBuffer&$ffff+7
-	.db $7e
-	.db 0	
-TextString13:
-	.dw $0146
-	.db "Timecode:"			;textstring
-	.db 1
-	.dw $0146+$12
-	.db 5
-	.dw SpcReportBuffer&$ffff+3
-	.db $7e
-	.db $00
-TextString14:
-	.dw $146+$12+$4
-	.db 5
-	.dw SpcReportBuffer&$ffff+2
-	.db $7e
-
-	.db $00
-TextString15:
-	.dw $004c
-
-	.db "- Nwarp Daisakusen -"			;textstring
-
-	.db 1
-	.dw $00d0
-	.db "Debug: Tablist Recorder"
-	.db $00	
-TextString16:
-	.dw $0206
-
-	.db "chsum ok "			;textstring
-	.db $00	
-TextString17:
-	.dw $0206
-
-	.db "chsum bad"			;textstring
-	.db $00	
-TextString18:
-	.dw $0146+13*2
-	.db 5
-	.dw VIrqCounter+1
-	.db $7e
-	.db $00
-
-TextString19:
-
-TextString20:
-
-TextString21:
-
-TextString22:
-
-TextString23:
-
-TextString24:
-
-TextString25:
-
-TextString26:
-
-TextString27:
-
-TextString28:
-
-TextString29:
-
-TextString30:
-	.dw $0186
-	.db "Volout:"			;textstring
-	.db 1
-	.dw $0186+$12
-	.db 5
-	.dw SpcReportBuffer&$ffff+5
-	.db $7e
-	.db $00
-TextString31:
-	.dw $186+$12+$4
-	.db 5
-	.dw SpcReportBuffer&$ffff+4
-	.db $7e
-
-	.db $00
-	
-TextString32:
-	.dw $0186+$18
-	.db "Joy5:"
-	.db 5
-	.dw JoyPortBuffer&$ffff+8
-	.db $7e
-	.db 0
-TextString33:
-	.dw $0186+$e+$18
-	.db 5
-	.dw JoyPortBuffer&$ffff+9
-	.db $7e
-	.db 0	
-TextString34:
-	.dw $01c6+$18
-	.db "Joy6:"
-	.db 5
-	.dw JoyPortBuffer&$ffff+10
-	.db $7e
-	.db 0
-TextString35:
-	.dw $01c6+$e+$18
-	.db 5
-	.dw JoyPortBuffer&$ffff+11
-	.db $7e
-	.db 0	
-TextString36:
-	.dw $0206+$18
-	.db "Joy7:"
-	.db 5
-	.dw JoyPortBuffer&$ffff+12
-	.db $7e
-	.db 0
-TextString37:
-	.dw $0206+$e+$18
-	.db 5
-	.dw JoyPortBuffer&$ffff+13
-	.db $7e
-	.db 0	
-TextString38:
-	.dw $0246+$18
-	.db "Joy8:"
-	.db 5
-	.dw JoyPortBuffer&$ffff+14
-	.db $7e
-	.db 0
-TextString39:
-	.dw $0246+$e+$18
-	.db 5
-	.dw JoyPortBuffer&$ffff+15
-	.db $7e
-	.db 0
-TextString40:
-TextString41:
-TextString42:
-TextString43:
-TextString44:
-TextString45:
-TextString46:
-TextString47:
-TextString48:
-TextString49:
-TextString50:
-TextString51:
-TextString52:
-TextString53:
-TextString54:
-TextString55:
-TextString56:
-TextString57:
-TextString58:
-TextString59:
-TextString60:
-TextString61:
-TextString62:
-TextString63:
-TextString64:
-TextString65:
-TextString66:
-TextString67:
-TextString68:
-TextString69:
-TextString70:
-TextString71:
-TextString72:
-TextString73:
-TextString74:
-TextString75:
-TextString76:
-TextString77:
-TextString78:
-TextString79:
-TextString80:
-TextString81:
-TextString82:
-TextString83:
-TextString84:
-TextString85:
-TextString86:
-TextString87:
-TextString88:
-TextString89:
-TextString90:
-TextString91:
-TextString92:
-TextString93:
-TextString94:
-TextString95:
-TextString96:
-TextString97:
-TextString98:
-TextString99:
-TextString100:
-TextString101:
-TextString102:
-TextString103:
-TextString104:
-TextString105:
-TextString106:
-TextString107:
-TextString108:
-TextString109:
-TextString110:
-TextString111:
-TextString112:
-TextString113:
-TextString114:
-TextString115:
-TextString116:
-TextString117:
-TextString118:
-TextString119:
-TextString120:
-TextString121:
-TextString122:
-TextString123:
-TextString124:
-TextString125:
-TextString126:
-TextString127:
-TextString128:
-TextString129:
-TextString130:
-TextString131:
-TextString132:
-TextString133:
-TextString134:
-TextString135:
-TextString136:
-TextString137:
-TextString138:
-TextString139:
-TextString140:
-TextString141:
-TextString142:
-TextString143:
-TextString144:
-TextString145:
-TextString146:
-TextString147:
-TextString148:
-TextString149:
-TextString150:
-TextString151:
-TextString152:
-TextString153:
-TextString154:
-TextString155:
-TextString156:
-TextString157:
-TextString158:
-TextString159:
-TextString160:
-TextString161:
-TextString162:
-TextString163:
-TextString164:
-TextString165:
-TextString166:
-TextString167:
-TextString168:
-TextString169:
-TextString170:
-TextString171:
-TextString172:
-TextString173:
-TextString174:
-TextString175:
-TextString176:
-TextString177:
-TextString178:
-TextString179:
-TextString180:
-TextString181:
-TextString182:
-TextString183:
-TextString184:
-TextString185:
-TextString186:
-
-.ends

+ 0 - 328
snes/loader/routines/variables.asm

@@ -1,328 +0,0 @@
-
-.ENUM $00				;1byte direct page variables for kernel and game mechanics
-TempBuffer		ds 20
-CurrentEvent		db
-FrameCounterLo		db
-FrameCounterHi		db
-SetIni			db
-ScreenMode		db
-MainScreen		db
-SubScreen		db
-ScreenBrightness	db
-BGTilesVram12		db
-BGTilesVram34		db
-BG1TilemapVram		db
-BG2TilemapVram		db
-BG3TilemapVram		db
-BG4TilemapVram		db
-SpriteTileOffsetVram	dw
-ObjSel			db
-BG1HOfLo		db
-BG1HOfHi		db
-BG1VOfLo		db
-BG1VOfHi		db
-BG2HOfLo		db
-BG2HOfHi		db
-BG2VOfLo		db
-BG2VOfHi		db
-HdmaFlags		db
-HdmaPause		db		;if msb is set, don't initiate further hdma transfers. this is useful when the rom hdma is trying to read from isnt present atm.
-ThreeBytePointerLo	db
-ThreeBytePointerHi	db
-ThreeBytePointerBank	db
-ThreeBytePointerLo2	db
-ThreeBytePointerHi2	db
-ThreeBytePointerBank2 	db
-BrightnessSpeed		db
-LastFrameLo		db
-LastFrameHi		db
-CGWsel			db
-CgadsubConfig		db
-FixedColourR		db
-FixedColourG		db
-FixedColourB		db
-InterruptEnableFlags	db
-IrqRoutineNumber	db
-IrqRoutineNumberBuffer	db				;backup in case multiple irqs are executed per frame. nmi writes this number back to irq number every frame
-IrqVCounter		dw
-IrqHCounter		dw
-W12SEL			db
-W34SEL			db
-WOBJSEL			db
-W1L			db
-W1R			db
-W2L			db
-W2R			db
-WBGLOG			db
-WOBJLOG			db
-WMS			db
-WSS			db
-Mosaic			db
-BGTilesVram2		dw
-Bg3Status		db
-PrintStringThreeBytePointerLo	db
-PrintStringThreeBytePointerHi	db
-PrintStringThreeBytePointerBank	db
-VramBg1Tilemap			dw
-VramBg2Tilemap			dw
-VramBg3Tilemap			dw
-VramBg4Tilemap			dw
-VramBg1Tiles			dw
-VramBg2Tiles			dw
-VramBg3Tiles			dw
-VramBg4Tiles			dw
-SetBGThreeBytePointerLo		db
-SetBGThreeBytePointerHi		db
-SetBGThreeBytePointerBank	db
-
-NMIOamUploadFlag	db
-NMIPaletteUploadFlag	db	;refresh palette during nmi?
-NMIBg1UploadFlag	db	;refresh bg1 tilemap during nmi?
-NMIBg2UploadFlag	db
-NMIBg3UploadFlag  db	;UploadBg3Map			db			;if this is not zero, upload tilemap to bg3
-CurrentMapNumber	db	;number of currently loaded map
-CurrentMapPointer	ds 3	;24bit pointer to current map file
-CurrentColMapPointer	ds 3	;24 bit pointer to current collision map
-BgScrollCounterX		db	;ranges from 0-7 inside one tile
-BgScrollCounterY		db
-BgMapCurrentPositionX		db	;current upper left tile on screen
-BgMapCurrentPositionY		db
-ScreenPixelPositionX		dw	;exact pixel position of upper left border for sprite position calculation
-ScreenPixelPositionY		dw	;exact pixel position of upper left border for sprite position calculation
-BgScrollRowUploadDisplace	db	;number of tiles to add/substract when uploading tilerows. this gets added to current position in map depending on the scrolling direction.(scroll right: add 28/scroll left: substract 1)
-BgScrollTilemapRowUploadDisplaceX	db	;number of tiles to add/substract when uploading tilerows. this gets added to current position in map depending on the scrolling direction.(scroll right: add 28/scroll left: substract 1)
-BgScrollTilemapRowUploadDisplaceY	db	;number of tiles to add/substract when uploading tilerows. this gets added to current position in map depending on the scrolling direction.(scroll right: add 28/scroll left: substract 1)
-BgScrollOffsetPointerTilesX		db	;pointer to current vertical column that holds the leftmost tiles onscreen(goes from 0-27)
-BgScrollOffsetPointerTilesY		db
-BgScrollOffsetPointerTilemapX		db	;pointer to current vertical column that holds the leftmost tiles onscreen for tilemap (goes from 0-32)
-BgScrollOffsetPointerTilemapY		db
-BgScrollTileSourcePointer		ds 3		;pointer to first tile of tileline to be uplodaded
-
-DmaFifoPointer				dw		;relative pointer to current free entry in buffer
-DmaFifoPointerIrq			dw
-DmaFifoSourcePointerLo			dw	
-DmaFifoSourcePointerBa			db
-DmaFifoOverhang				dw
-DmaFifoTotalBytesTransferred		dw		;used to guesstimate how much time we have left for transfers
-
-ObjectListPointer			dw		;pointer to next free object in object list
-ObjectListPointerCurrent		dw		;pointer to current object in object list, used to set direct register
-CurrentObjectNumber			db		;number of currently selected object in list
-OamBufferPointer			dw		;pointer to current sprite in oam buffer
-OamZsortBufferPointer			dw		;pointer to current sprite in oam zsort buffer
-OamZsortSpriteNumber			db		;number of sprites to sort
-OamAniListStraightRepeatFlag		dw
-
-FocusScreenFlags	db		;flags for focus
-					;bit0=enable focus on object
-FocusScreenObject	db		;number of object in object list to focus to
-FocusScreenSpline	db		;number of preset table to use for scrolling depending on distance to object(linear,sine,exp etc)
-FocusScreenXWait	db
-FocusScreenYWait	db
-
-CollisionPixelX		dw
-CollisionPixelY		dw
-CollisionTemp		dw
-PalTemp				db		;used for object subroutine
-ExitCollisionPointer	dw		;bits0-14 contain number of exit.   old:;bits0-14 contain pointer to an entry in the exit list. if bit15 is set, this exit has been hit and needs to be procesed.
-R1			db		;random number generator buffers
-R2			db
-R3			db
-R4			db
-ColObjListPointer	dw
-HdmaListPointer		dw
-VwfFontPointerLo	ds 3
-
-
-SpcTempBuffer			ds 8		;temp buffer for spc stuff
-SpcCurrentStreamSet		db
-SpcHandlerState			db
-SpcHandlerArgument0		db
-SpcHandlerArgument1		db
-SpcHandlerArgument2		db
-SpcCmdFifoStart			db
-SpcCmdFifoEnd			db
-
-PtPlayerDataPointerLo		db	;assumes dreg: $0000
-PtPlayerDataPointerHi		db	;assumes dreg: $0000
-PtPlayerDataPointerBa		db	;assumes dreg: $0000
-PtPlayerCurrentSong		db	;assumes dreg: $0000
-PtPlayerCurrentSamplePack	db
-PtPlayerCurrentSoundEffect	db
-
-PtPlayerSmplBufferPosLo		db	;not needed at all
-PtPlayerSmplBufferPosHi		db
-SpcUploadedFlag				db	;msb set=song upload complete and playing. bit6 set=sample pack uploaded
-VideoHandlerState			db
-
-CheckJoypadMode				db	;0=1 player, 1=8 players, 2=instruments + 1 joypad
-
-FontSelector		db
-FixedStringLength		db
-PrintStringPalette		db
-
-MenuFileThreeBytePointerLo		db
-MenuFileThreeBytePointerHi		db
-MenuFileThreeBytePointerBank	db
-MenuRowsThreeBytePointerLo		db
-MenuRowsThreeBytePointerHi		db
-MenuRowsThreeBytePointerBank	db
-MenuRowsThreeByteOptionPointerLo	db
-MenuRowsThreeByteOptionPointerHi	db
-MenuRowsThreeByteOptionPointerBank	db
-MenuRowsThreeByteCodePointerLo	db
-MenuRowsThreeByteCodePointerHi	db
-MenuRowsThreeByteCodePointerBank	db
-LoadMenuInitialOffset		dw
-LoadMenuInitialOptionOffset	dw
-LoadMenuVerticalSpacing		dw
-LoadMenuNumberOfRows		db
-LoadMenuCurrentRow		db
-LoadMenuStringPosLo		db
-LoadMenuStringPosHi		db
-LoadMenuPalUnselSel		db
-LoadMenuDoInit			db
-BattleSubroutine		db
-HdmaListCounter			db	;counter used by hdma handler to switch through channels
-
-TempBufferIrq			ds 8		;Temporary Buffer for irq routines
-BattleMusicState		db
-CurrentTablistPointer		ds 3
-.ENDE
-
-
-
-.ENUM $200		;2-byte adresses for game status stuff
-TempBufferTest		ds 4
-Hdma3dScrollCountV	db	;amount of lines to wait before hdma table
-CurrentBattleFile	db
-MapStartPosX	db		;map start position set by external routine
-MapStartPosY	db
-MapSizeX	db		;/must not be seperated cause they may be written to both at the same time in word-mode
-MapSizeY	db		;\
-BGMapStartPosX	db		;start position for bg upload(may differ from sprite location if near a border)
-BGMapStartPosY	db
-
-CurrentStringTarget	db	;current position in bg1 tilemap to write to, 2 bytes
-CurrentStringTargetHi	db
-FixedColourRsave	db
-FixedColourGsave	db
-FixedColourBsave	db
-CpuUsageScanline		db
-SpcStreamVolume			db
-SpcSEVolume			db
-SpcSEPitch			db
-SpcSongSpeed			db		;default $a0
-SpcSongChMask			db		;default $0f
-SpcReportType			db		;0=none 1=timecode 2=channel-levels(vol out) 3=special mod command
-
-SpcCmdFifo			ds 64
-MessageDeleteCounter		dw		;inactive when zero, delete message when 1(then set zero), decrease each frame when not 0 or 1						
-
-HdmaFadeInOutState		db		;bit7set=fade in/bit7clear=fade out,bit6set=done fading bit0-5=current state in LUT for window and mosiac size
-MainCharaObjectNumber		db
-MainCharaXPos			dw
-MainCharaYPos			dw
-ExitMapTarget			dw		;target map
-ExitXTarget			dw		;target x-pos on map
-ExitYTarget			dw		;target y-pos on map
-
-Pseudo3dScrollUpdateFlag	db		;if this isn't zero, update scroll table
-CurrentLevel			dw
-PlayerState			db		;current mode of player characters. 0=active battle 1=player select menu(start sitting. when start pressed for that player, switch to subroutine that is similar to battle, but without being able to fight) 2=results screen.
-PlayersPresentFlags		db		;flags to signalize players connected.
-ActivePlayers			db		;number of alive players 		
-WinningPlayer			db		;number of player that has won the match. $ff=invalid
-IrqBrightnessIncDec		db		;just a flag. bit0 set=increase. bit1 clear=decrease. bit8=ack/done
-BrightnessEventBuffer		db		;buffer event routine to jum p to after brightness inc/dec
-SpcStreamFrame			dw
-SpcSoundEffectFlipFlag		dw		;flag alternating between each sound effect upload so that spc doesnt trigger the same one twice.
-BattleFinished			db		;$80 if battle is finished
-IntroScene3ScrollPoint		dw
-VideoFrames				db
-VideoFrameRate			dw		;ANDed with framecounter. 0=60hz, 1=30hz, 3=15hz etc.
-CurrentVideo			db
-CurrentVideoFrame		db
-PlayerSelectScrollCounter	dw
-WinningPlayerPointer		dw
-RandomLevelCounter			db	;msb=shuffle direction. bits0-3 level number
-RandomStreamCounter			db	;msb=shuffle direction. bits0-3 Streamset number
-SpecialReportOld			db
-HdmaScrollPointerBuffer	dw
-GravityCutOffYPos					dw	;y-pos of object(with 4bit precision)	that triggers delete if bigger and gravity affected
-GravObjectCounter						db	;counter of particle/gravity objects to create to prevent slowdown and such
-MaxGravObjCount						db		;max allowed particles per frame. dont create new ones if exceeded
-EventJumper								db		;variable to select which event to jump to in debug menu
-CollisionObjPointer				dw	;pointer to object that just has collided with calling obj
-Reg3000WriteVar				db
-VIrqCounter					dw
-ExtIrqCounter				dw
-CartChecksum				db
-.ENDE
-
-.ENUM $7e0300
-JoyPort1Data1Io0Buffer		ds 4
-JoyPort1Data2Io0Buffer		ds 4
-JoyPort2Data1Io0Buffer		ds 4
-JoyPort2Data2Io0Buffer		ds 4
-
-JoyPort1Data1Io1Buffer		ds 4
-JoyPort1Data2Io1Buffer		ds 4
-JoyPort2Data1Io1Buffer		ds 4
-JoyPort2Data2Io1Buffer		ds 4
-VectorAngleSMCode			ds 9	;8 inc/decs per frame + rtl
-
-LoadMenuStringBuffer		ds 9
-PrintStringBuffer0		ds 16
-;.ende
-
-;.ENUM $7e0300
-JoyPortBuffer			ds 16		;8 joypads max, word entries.
-						;0=port1 joy 1 
-						;2=port1 joy 2 
-						;4=port1 joy 3 
-						;6=port1 joy 4 
-						;8=port2 joy 1
-						;a=port2 joy 2
-						;c=port2 joy 3
-						;e=port2 joy 4
-JoyPortBufferOld			ds 16
-JoyPortBufferTrigger			ds 16
-
-;joypad buttons:
-;15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
-;b  y  se st U  D  L R a x l r 0 0 0 0
-
-
-
-PaletteBuffer			ds $0200	;bg3 palettes: buffer $0-$20 (4 different 4-color palettes, for text
-Bg1MapBuffer			ds $1000
-Bg2MapBuffer			ds $800
-Bg3MapBuffer			ds $0800
-Bg4MapBuffer			ds $1
-OamZSortBuffer			ds $0500	;256 entries, each 6 bytes
-OamZSortObjList			ds 128*2		;prioritized list of objects that need priority processing(2 byte relative pointers)
-;ZSortOamPriorityBuffer		ds $0040
-OamBuffer			ds $0200
-OamPriorityBuffer		ds $0020
-DmaFifoBuffer			ds $1000 	;DmaFifoEntryLength*256
-ObjectList			ds $0800	;32 entries, each 32 bytes
-ExitList			ds $0080	;16 entries, each 8 bytes
-ColObjList			ds $00c0	;32 entries, each 4 bytes
-HdmaBuffer			ds $0340
-HdmaBuffer1			ds $0340
-HdmaBuffer2			ds $0340
-HdmaBuffer3			ds $0340
-HdmaBuffer4			ds $0340
-HdmaBuffer5			ds $0340
-HdmaDataBuffer1			ds $0400
-HdmaSpcBuffer			ds 200		;streaming table, uses channel 7
-TextBoxMenuBuffer		ds $0040	;8 entries * 8
-SpcReportBuffer			ds 16		;8 entries, each 2 bytes
-									;0=none
-									;2=timecode
-									;4=channel levels
-									;6=special mod cmd
-Hdma3dScrollBuffer		ds 400		;80 entries, each 5 bytes
-WinnerArray				ds 8*1
-.ENDE

+ 0 - 176
snes/loader/routines/vblanknmi.asm

@@ -1,176 +0,0 @@
-;this nmi uses a maximum of 20 scanlines while streaming brr frames to the spc
-NMI:
-	php
-	rep #$39
-	pha
-	phb
-	phd
-	phx
-	phy
-	lda.w #$0000
-	tcd
-	sep #$20
-	
-	lda.l $004210			;reset nmi flag		
-	lda #$81
-	pha
-	plb
-	stz.w $4201			;clear iobit
-
-	lda.b HdmaFlags		;check which hdma channels need to be activated
-	and #$fc		;exclude channel #0,1(reserved for normal dma)
-	sta.w $420C		;set hdma channels and disable dma channel
-
-
-	rep #$31
-	lda W12SEL
-	sta $2123
-	lda W1L
-	sta $2126
-	lda W2L
-	sta $2128
-	lda WBGLOG
-	sta $212a
-	lda WMS
-	sta $212e
-
-	sep #$20
-	lda WOBJSEL
-	sta $2125
-	lda.b Mosaic
-	sta.w $2106
-
-	sep #$20	
-  	ldx FrameCounterLo	;increment word framecounter
-  	inx				;
-  	stx FrameCounterLo		;
-
-  	lda ScreenMode		;set screenmode and bg sizes
-  	sta $2105			;
-  	lda MainScreen		;setup main and subscreen
-  	sta $212c			;
-  	lda SubScreen		;setup main and subscreen
-  	sta $212d			;
-		;
-  	lda BGTilesVram12		;set offsets in vram for tiles
-  	sta $210B			;of bg1 and bg2
-  	lda BGTilesVram34		;set offsets in vram for tiles
-  	sta $210C			;of bg1 and bg2
-  	lda BG1TilemapVram	;set offset of bg1 tilemap in  vram
-  	sta $2107			;
-  	lda BG2TilemapVram	;set offset of bg2 tilemap in  vram
-  	sta $2108			;
-  	lda BG3TilemapVram	;set offset of bg3 tilemap in  vram
-  	sta $2109			;
-  	lda BG4TilemapVram	;set offset of bg3 tilemap in  vram
-  	sta $210a			;
-
-	lda.w CGWsel		;colour add/sub config
-	sta $2130
-	lda.w CgadsubConfig
-	sta $2131
-	lda.w FixedColourB
-	and.b #%00011111
-	ora.b #%10000000
-	sta $2132
-	lda.w FixedColourG
-	and.b #%00011111
-	ora.b #%01000000
-	sta $2132
-	lda.w FixedColourR
-	and.b #%00011111
-	ora.b #%00100000
-	sta $2132
-
-  	lda BG1HOfLo		;set bg1 h-offset
-	sta $210d			;
-  	lda BG1HOfHi		;
-	sta $210d			;
-  	lda BG1VOfLo		;set bg1 v-offset
-	sta $210e			;
-  	lda BG1VOfHi		;
-	sta $210e			;
-  	lda BG2HOfLo		;set bg2 h-offset
-	sta $210f			;
-  	lda BG2HOfHi		;
-	sta $210f			;
-  	lda BG2VOfLo		;set bg2 v-offset
-	sta $2110			;
-  	lda BG2VOfHi		;
-	sta $2110			;
-
-	lda ObjSel
-	sta $2101
-
-
-;this (writing to regs $4209,$4207,$4200) somehow breaks vblank flag setting in reg $4210,$4200)
-	lda.b IrqRoutineNumberBuffer
-	sta.b IrqRoutineNumber		;if this is zero, irqs are disabled
-	beq NmiDisableHIrq
-
-	rep #$31			;store current h-counter in reg
-	lda.b IrqVCounter
-	sta.w $4209			;v
-	lda.b IrqHCounter
-	sta.w $4207			;h
-
-	sep #$20
-	lda.b InterruptEnableFlags
-	ora.b #%00110000		;enable v and h irq, will take effect next frame. irq is only triggered if both positions match
-	sta.b InterruptEnableFlags
-	sta.w $4200			;should be ok. hope it breaks nothing
-
-	bra NmiHIrqDone
-
-NmiDisableHIrq:
-	sep #$20
-	lda.b InterruptEnableFlags
-	and.b #%11001111		;disable h-irq
-	sta.b InterruptEnableFlags
-	sta.w $4200
-
-NmiHIrqDone:
-
-
-	sep #$20
-	lda.b #$80
-	sta.w $2100
-
-	
-	
-	
-;	jsr ProcessHdmaList
-	jsr IrqCheckTilemapFlags
-	jsr ProcessDmaFifo
-	jsr IrqBrightness
-;	jsr DMATileMapToVramBG3	
-
-;moved to irq. that way, screen might turn black during long transfers, but at least the data gets uploaded reliably 	
-  	lda ScreenBrightness	;setup screen brightness
-  	and.b #$7f
-  	sta $2100	
-
-	
-	jsr Random		;update random numbers
-	jsr SpcHandlerMain
-
-
-
-	rep #$31
-	lda.b CheckJoypadMode
-	and.w #%11
-	asl a
-	tax
-	sep #$20
-	jsr (CheckJoypadModeLUT,x)
-	
-	rep #$39
-	ply
-	plx
-	pld
-	plb
-	pla
-	plp
-	rts
-	rti				;return from nmi
-	

+ 0 - 2
snes/loader/spclinkfile

@@ -1,2 +0,0 @@
-[objects]
-data/apu/apucode.o