From 5b6e62a4282e0b9939ecc148222c6f29586f0942 Mon Sep 17 00:00:00 2001 From: optixx Date: Fri, 16 Oct 2009 07:43:59 +0200 Subject: [PATCH] cleanup --- snes/loader/conv_rle.py | 36 - snes/loader/data/apu/amigaperiodtable.tbl | 61 - snes/loader/data/apu/apucode.asm | 3326 -------------------- snes/loader/data/apu/pitchtable2.tbl | Bin 1736 -> 0 bytes snes/loader/data/apu/pitchtable_new.tbl | 860 ----- snes/loader/data/apu/vibratotable.tbl | Bin 32 -> 0 bytes snes/loader/data/battle_sky.clr | Bin 512 -> 0 bytes snes/loader/data/blanktile.pic | Bin 64 -> 0 bytes snes/loader/data/cpuusage.clr | Bin 512 -> 0 bytes snes/loader/data/cpuusage.pic | Bin 512 -> 0 bytes snes/loader/data/font/asciitablejap.tbl | 1 - snes/loader/data/font/font1.pic | Bin 2304 -> 0 bytes snes/loader/data/font/font1pal.clr | Bin 512 -> 0 bytes snes/loader/data/sounds/hit.brr | Bin 738 -> 0 bytes snes/loader/linkfile | 2 - snes/loader/main.asm | 310 -- snes/loader/makefile | 50 - snes/loader/routines/audiostreams.asm | 4 - snes/loader/routines/backgroundfiles.asm | 22 - snes/loader/routines/bgmodes.asm | 272 -- snes/loader/routines/defines.asm | 255 -- snes/loader/routines/dmafifo.asm | 975 ------ snes/loader/routines/eventroutines.asm | 90 - snes/loader/routines/gfxvrammisc.asm | 662 ---- snes/loader/routines/irq.asm | 362 --- snes/loader/routines/joypadread.asm | 126 - snes/loader/routines/levelfiles.asm | 1128 ------- snes/loader/routines/memoryclear.asm | 160 - snes/loader/routines/menufiles.asm | 320 -- snes/loader/routines/menusubroutines.asm | 174 - snes/loader/routines/menusystem.asm | 706 ----- snes/loader/routines/miscdata.asm | 530 ---- snes/loader/routines/oamanimationlists.asm | 1045 ------ snes/loader/routines/oammanager.asm | 3092 ------------------ snes/loader/routines/oamobjects.asm | 94 - snes/loader/routines/oamsubroutines.asm | 20 - snes/loader/routines/oamvectoranglelut.asm | 2054 ------------ snes/loader/routines/printstring.asm | 756 ----- snes/loader/routines/randomnumbergen.asm | 40 - snes/loader/routines/samplepacks.asm | 34 - snes/loader/routines/sinetables.asm | 74 - snes/loader/routines/songs.asm | 16 - snes/loader/routines/spcinterface.asm | 1152 ------- snes/loader/routines/spritedata.asm | 28 - snes/loader/routines/textstrings.asm | 648 ---- snes/loader/routines/variables.asm | 328 -- snes/loader/routines/vblanknmi.asm | 176 -- snes/loader/spclinkfile | 2 - 48 files changed, 19991 deletions(-) delete mode 100644 snes/loader/conv_rle.py delete mode 100644 snes/loader/data/apu/amigaperiodtable.tbl delete mode 100644 snes/loader/data/apu/apucode.asm delete mode 100644 snes/loader/data/apu/pitchtable2.tbl delete mode 100644 snes/loader/data/apu/pitchtable_new.tbl delete mode 100644 snes/loader/data/apu/vibratotable.tbl delete mode 100644 snes/loader/data/battle_sky.clr delete mode 100644 snes/loader/data/blanktile.pic delete mode 100644 snes/loader/data/cpuusage.clr delete mode 100644 snes/loader/data/cpuusage.pic delete mode 100644 snes/loader/data/font/asciitablejap.tbl delete mode 100644 snes/loader/data/font/font1.pic delete mode 100644 snes/loader/data/font/font1pal.clr delete mode 100644 snes/loader/data/sounds/hit.brr delete mode 100644 snes/loader/linkfile delete mode 100644 snes/loader/main.asm delete mode 100644 snes/loader/makefile delete mode 100644 snes/loader/routines/audiostreams.asm delete mode 100644 snes/loader/routines/backgroundfiles.asm delete mode 100644 snes/loader/routines/bgmodes.asm delete mode 100644 snes/loader/routines/defines.asm delete mode 100644 snes/loader/routines/dmafifo.asm delete mode 100644 snes/loader/routines/eventroutines.asm delete mode 100644 snes/loader/routines/gfxvrammisc.asm delete mode 100644 snes/loader/routines/irq.asm delete mode 100644 snes/loader/routines/joypadread.asm delete mode 100644 snes/loader/routines/levelfiles.asm delete mode 100644 snes/loader/routines/memoryclear.asm delete mode 100644 snes/loader/routines/menufiles.asm delete mode 100644 snes/loader/routines/menusubroutines.asm delete mode 100644 snes/loader/routines/menusystem.asm delete mode 100644 snes/loader/routines/miscdata.asm delete mode 100644 snes/loader/routines/oamanimationlists.asm delete mode 100644 snes/loader/routines/oammanager.asm delete mode 100644 snes/loader/routines/oamobjects.asm delete mode 100644 snes/loader/routines/oamsubroutines.asm delete mode 100644 snes/loader/routines/oamvectoranglelut.asm delete mode 100644 snes/loader/routines/printstring.asm delete mode 100644 snes/loader/routines/randomnumbergen.asm delete mode 100644 snes/loader/routines/samplepacks.asm delete mode 100644 snes/loader/routines/sinetables.asm delete mode 100644 snes/loader/routines/songs.asm delete mode 100644 snes/loader/routines/spcinterface.asm delete mode 100644 snes/loader/routines/spritedata.asm delete mode 100644 snes/loader/routines/textstrings.asm delete mode 100644 snes/loader/routines/variables.asm delete mode 100644 snes/loader/routines/vblanknmi.asm delete mode 100644 snes/loader/spclinkfile diff --git a/snes/loader/conv_rle.py b/snes/loader/conv_rle.py deleted file mode 100644 index cff244e..0000000 --- a/snes/loader/conv_rle.py +++ /dev/null @@ -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 -#include - -const char _rom[ROM_SIZE] PROGMEM = { -''') - -for idx,c in enumerate(data): - c = ord(c) - if idx> 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: diff --git a/snes/loader/data/apu/pitchtable2.tbl b/snes/loader/data/apu/pitchtable2.tbl deleted file mode 100644 index 296c1c61aa97f8cbd77fe1662a19c43f07b10ab4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1736 zcmWmCi+|789mnx{zdz@EFTZPUzuZGYkR~pv5JUy3OX_}4>z1`HDN4<~nAJ#Acd3@4 zQd3fOE85U7$_T2hdbo|089K^?Dm7Zl&R)-d;dLXo;`xtrcDJ~dozrY>R!WnK%)yOg z8eM6yH)DPJs%Oj6Hq}2=?|R+Hy7{Tab&l1Ju01m4U~--0xwY=s9A2|Jsc+J$#QupF z5{eQY#FxY;#aG1jjJp%NB(`a6bK5gXIv!aX z*)K97@=C$d}+R*@1ggS z_lS3!cZGMhcZ|2d+s@m-8{?(-w&%R3%Cp^5=9%xA>KX3o<7w+@z|D7Cy6J9$>vx|zKRZ{P)6Nm6(%IycIi=1VXNoh*8RGPEIyfzz z22QdQa$M($eb2sTe{Y|#tL)wOr}jE~rM=iLwx`+S>=E`LySJTh=i1He3_Hb+wS%^{ zf46?IZd#YEbJhv#h_%n!X>GCATdS@2tOeE_Ylbz^dfggk4YK-K-K-8)u9a;yw$iL* zE6$3ryq2<_=m+|a{!w4n)%vvlRv*^;b*27HZ`S2{jb5pj>V>*Q&(hQNB>jdSsfX&p z`X$|4ch#MAJKaiW>r9=Y>*{2kphG%Ld$px&=*Q}Tx~p!f>*|WSsLrWV>bN?ls?>h9 zN9|HO)E4!LTBp{iRcg6-%K=o1GRcF;v<*7ER zm1?fCRAZH)>Z??htP)kM3aN1AR~}_4s%O+=`Bm=AUAZkc<(gcTOL9TZ%NaQ--^tf< zRI22F?2|q6g;dCP*(#f4gRGae@}YbnD`c50l_j!J=1Ganky$cRrpr{BEE8m$jFC}N zB*W!ZDU?AnKnkR<^p+mdRXR&2X)k%wMp{dbw2)@fL^7qJWJsFSlT=BOT9PR75+fmr zlrRa1Ph7D@3#EoUNitGI&8`97DjluNjX3pkJOu!O~& z%~^blGdY9P_$H@t5+`sx$8jvja5P8qHICpg4&^H>NhBL?j{q)j9mkupzDw1FgKE)IKj>q^7zv3Yt;68rAJ>10|{Dj-Mg`2p6A8{Sm z@B^;m3NGW{_!lnX0=`Ez&f}jri!(TlQ#gqe_zuVMExy6mIEJrq6o*lTLpX?k-~jgH zOYFm5{2jYdi7&7VJ5hnp@fmhtJGS9dY{eFA#wKjUC)j|GQI7RkhmWupf5RGlh%&6k z2UvxbSb@J{IhNslyoaTD7o}K&#aM)e#sbX8Jj}&AD8bt(#vIJXUyNCJ3xCE;{0TEK z9n*|AF%?rV8Iv#(6O8frBgWwkjKvt^b&SR+jKph35k_D*hGD4jDqg`KP-qOnU<|@Q zV*p;pODHh42Q4&yANmXc*S*CEz<)p?518u{#o<@GfY0>2jqhMHv004&+2^#TT=l$`# zKfWmS|Ml@~xcTVzYW?42Sg#xAasOph864~9r?sD+9yX%w?l6wa!?gE zsq~a(J57J*-~jrPt5?fktbOTyzWiuzPW^DO4|}W7Hf43X-PHcGWSHuk$bITM`Q+*! zBVnnD+}7pRd6b6h3!RD%DsT(%qS7qJ z|KV5RG2#<^DY2-1{{WI}EKbP?7v1e$B zN6)#aAFihM*T06JtXD2~ZpjOP5&dUWf%Z*wPO)hC)O}sQP^;-gP>OUTTy-m{ee{>9 zmsaW@`Lv$lt-}q|Z90^A(poq5NQ3YT&#eD))i|IA$Rsbu>XzvvH}Q1Ptx|0_^Q5mY zOtBOjnKHy{gbjS6Kg8~?!9wys##Z<`Tmlzwai_o6Y2qi}x6Bk{{RlQ=dpcY%4e6gysqQq9|RpU?`TVMAlf<2r;ChN zXy(!DJ{k0kH2XA)e?5F@vP-2A{#VG`*w`poQGDSn1V0}g8G1Y3#)&xNFdD9^7sW?@ ioioAEJ!t0lG7l8at)4B{0Q^8dd$pVNlig%!ru%Yiu006>q2_^sl diff --git a/snes/loader/data/sounds/hit.brr b/snes/loader/data/sounds/hit.brr deleted file mode 100644 index ed8e6375b87fe5fc5ab0f525a78896f1a9851f29..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 738 zcmV<80v-K;@DC914*&r!ko`Us(u>u%Ro!cATZ;Hg|xhTJJ#JQ z2hGe(A^!vZFZHpsBEt~j;7T75q_`E$`81;MO{7oc1M~nVDnX<>Fy;O}SQXo(Dih06 z>^yD#ps3imiNDHkF|Z>-BO^jXR5!HH68->_^3w3Mcv(wN5r0^EE9wp%t-=uvX z0UtSU{wttAOb^NmsTsMX9|6D;wX)P3tYM`q6C4$>OqBC8;W}0S0`ROJ1GUioKLH$+ z0?qfTd@cd>q!IBjEK%=r@2F}KFXQkK00E@5;{6?6&p$qt!-Y5i;l;tglo7+>06rl< zYM^CgWmIHUWLKo`)c^qU@xl(2*SP`5kmBC1N<+(>z){kknD=9>dxu_QGd1fbt^e_W)85K!7lBA_VZ|zuth&px7wg-S6;#0}=%U0|O#XfH5Et9wFZh@POmt z|MJ7cz)yhk0|GPVA3r{TLgMisEiD1hfbr1o5dZP*5P<&hAK@<@G5>%rGVw7Y0Rj$y UApjo_@!$Xe0RR91000000K=>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 diff --git a/snes/loader/routines/bgmodes.asm b/snes/loader/routines/bgmodes.asm deleted file mode 100644 index 336ec8a..0000000 --- a/snes/loader/routines/bgmodes.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/snes/loader/routines/defines.asm b/snes/loader/routines/defines.asm deleted file mode 100644 index 776b1e4..0000000 --- a/snes/loader/routines/defines.asm +++ /dev/null @@ -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 -;************************************************************************* - - diff --git a/snes/loader/routines/dmafifo.asm b/snes/loader/routines/dmafifo.asm deleted file mode 100644 index ee5096d..0000000 --- a/snes/loader/routines/dmafifo.asm +++ /dev/null @@ -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 - - - - - - - - \ No newline at end of file diff --git a/snes/loader/routines/eventroutines.asm b/snes/loader/routines/eventroutines.asm deleted file mode 100644 index f03b05a..0000000 --- a/snes/loader/routines/eventroutines.asm +++ /dev/null @@ -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 - \ No newline at end of file diff --git a/snes/loader/routines/gfxvrammisc.asm b/snes/loader/routines/gfxvrammisc.asm deleted file mode 100644 index c3abecc..0000000 --- a/snes/loader/routines/gfxvrammisc.asm +++ /dev/null @@ -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 - - - - diff --git a/snes/loader/routines/irq.asm b/snes/loader/routines/irq.asm deleted file mode 100644 index d3e0b55..0000000 --- a/snes/loader/routines/irq.asm +++ /dev/null @@ -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 - \ No newline at end of file diff --git a/snes/loader/routines/joypadread.asm b/snes/loader/routines/joypadread.asm deleted file mode 100644 index 91d3b99..0000000 --- a/snes/loader/routines/joypadread.asm +++ /dev/null @@ -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 diff --git a/snes/loader/routines/levelfiles.asm b/snes/loader/routines/levelfiles.asm deleted file mode 100644 index eb60004..0000000 --- a/snes/loader/routines/levelfiles.asm +++ /dev/null @@ -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 diff --git a/snes/loader/routines/memoryclear.asm b/snes/loader/routines/memoryclear.asm deleted file mode 100644 index 0610c07..0000000 --- a/snes/loader/routines/memoryclear.asm +++ /dev/null @@ -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 - - \ No newline at end of file diff --git a/snes/loader/routines/menufiles.asm b/snes/loader/routines/menufiles.asm deleted file mode 100644 index 1349098..0000000 --- a/snes/loader/routines/menufiles.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/snes/loader/routines/menusubroutines.asm b/snes/loader/routines/menusubroutines.asm deleted file mode 100644 index 6132d80..0000000 --- a/snes/loader/routines/menusubroutines.asm +++ /dev/null @@ -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 - \ No newline at end of file diff --git a/snes/loader/routines/menusystem.asm b/snes/loader/routines/menusystem.asm deleted file mode 100644 index 95f844d..0000000 --- a/snes/loader/routines/menusystem.asm +++ /dev/null @@ -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 - diff --git a/snes/loader/routines/miscdata.asm b/snes/loader/routines/miscdata.asm deleted file mode 100644 index 5d37e50..0000000 --- a/snes/loader/routines/miscdata.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/snes/loader/routines/oamanimationlists.asm b/snes/loader/routines/oamanimationlists.asm deleted file mode 100644 index b340412..0000000 --- a/snes/loader/routines/oamanimationlists.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/snes/loader/routines/oammanager.asm b/snes/loader/routines/oammanager.asm deleted file mode 100644 index 8abe32b..0000000 --- a/snes/loader/routines/oammanager.asm +++ /dev/null @@ -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 - \ No newline at end of file diff --git a/snes/loader/routines/oamobjects.asm b/snes/loader/routines/oamobjects.asm deleted file mode 100644 index 5f8ab3a..0000000 --- a/snes/loader/routines/oamobjects.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/snes/loader/routines/oamsubroutines.asm b/snes/loader/routines/oamsubroutines.asm deleted file mode 100644 index 511ca32..0000000 --- a/snes/loader/routines/oamsubroutines.asm +++ /dev/null @@ -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 diff --git a/snes/loader/routines/oamvectoranglelut.asm b/snes/loader/routines/oamvectoranglelut.asm deleted file mode 100644 index 3f25ea2..0000000 --- a/snes/loader/routines/oamvectoranglelut.asm +++ /dev/null @@ -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 - \ No newline at end of file diff --git a/snes/loader/routines/printstring.asm b/snes/loader/routines/printstring.asm deleted file mode 100644 index bce66cb..0000000 --- a/snes/loader/routines/printstring.asm +++ /dev/null @@ -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 - \ No newline at end of file diff --git a/snes/loader/routines/randomnumbergen.asm b/snes/loader/routines/randomnumbergen.asm deleted file mode 100644 index d88b6dd..0000000 --- a/snes/loader/routines/randomnumbergen.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/snes/loader/routines/samplepacks.asm b/snes/loader/routines/samplepacks.asm deleted file mode 100644 index 1f9974e..0000000 --- a/snes/loader/routines/samplepacks.asm +++ /dev/null @@ -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 diff --git a/snes/loader/routines/sinetables.asm b/snes/loader/routines/sinetables.asm deleted file mode 100644 index 3dc322a..0000000 --- a/snes/loader/routines/sinetables.asm +++ /dev/null @@ -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: \ No newline at end of file diff --git a/snes/loader/routines/songs.asm b/snes/loader/routines/songs.asm deleted file mode 100644 index e60c174..0000000 --- a/snes/loader/routines/songs.asm +++ /dev/null @@ -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 diff --git a/snes/loader/routines/spcinterface.asm b/snes/loader/routines/spcinterface.asm deleted file mode 100644 index fefdd23..0000000 --- a/snes/loader/routines/spcinterface.asm +++ /dev/null @@ -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 - - diff --git a/snes/loader/routines/spritedata.asm b/snes/loader/routines/spritedata.asm deleted file mode 100644 index ed895e9..0000000 --- a/snes/loader/routines/spritedata.asm +++ /dev/null @@ -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 diff --git a/snes/loader/routines/textstrings.asm b/snes/loader/routines/textstrings.asm deleted file mode 100644 index 91f33cd..0000000 --- a/snes/loader/routines/textstrings.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/snes/loader/routines/variables.asm b/snes/loader/routines/variables.asm deleted file mode 100644 index 9cb9c53..0000000 --- a/snes/loader/routines/variables.asm +++ /dev/null @@ -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 diff --git a/snes/loader/routines/vblanknmi.asm b/snes/loader/routines/vblanknmi.asm deleted file mode 100644 index 86d867f..0000000 --- a/snes/loader/routines/vblanknmi.asm +++ /dev/null @@ -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 - diff --git a/snes/loader/spclinkfile b/snes/loader/spclinkfile deleted file mode 100644 index 7f835d3..0000000 --- a/snes/loader/spclinkfile +++ /dev/null @@ -1,2 +0,0 @@ -[objects] -data/apu/apucode.o