o add monitor

This commit is contained in:
David Voswinkel 2009-07-20 19:05:40 +02:00
parent 56713860ac
commit a7270acdf1
50 changed files with 19969 additions and 18 deletions

View File

@ -9,7 +9,7 @@ OBJS=irqtest.o
APP=irqtest.smc APP=irqtest.smc
GFX= GFX=
all: clean $(APP) check all: clean $(APP)
run: run:
zsnes $(APP) zsnes $(APP)
@ -25,9 +25,6 @@ linkfile:
optixx.inc: optixx.pcx optixx.inc: optixx.pcx
wine tools/pcx2snes.exe optixx.pcx -b2 -nOptixx -ooptixx.inc wine tools/pcx2snes.exe optixx.pcx -b2 -nOptixx -ooptixx.inc
check:
ucon64 -chk $(APP)
rm -fv *.bak
smc: smc:
ucon64 -smc $(APP) ucon64 -smc $(APP)
rm -fv *.bak rm -fv *.bak

View File

@ -16,6 +16,9 @@
.ROMBANKSIZE $8000 ; Every ROM bank is 32 KBytes in size .ROMBANKSIZE $8000 ; Every ROM bank is 32 KBytes in size
.ROMBANKS 8 ; 2 Mbits - Tell WLA we want to use 8 ROM Banks .ROMBANKS 8 ; 2 Mbits - Tell WLA we want to use 8 ROM Banks
.LOROM
.COMPUTESNESCHECKSUM
.SNESHEADER .SNESHEADER
ID "SNES" ; 1-4 letter string, just leave it as "SNES" ID "SNES" ; 1-4 letter string, just leave it as "SNES"

View File

@ -48,15 +48,17 @@ Start_do:
; Setup Video modes and other stuff, then turn on the screen ; Setup Video modes and other stuff, then turn on the screen
jsr SetupVideo jsr SetupVideo
lda #$81 lda #$00
sta $4200 sta $4200
rep #$31
Infinity: Infinity:
lda PalNum ; lda.b PalNum
clc ; clc
adc #$01 ; adc.w #$01
and #$ff ; If > palette starting color > 24 (00011100), make 0 ; and.w #$ffff ; If > palette starting color > 24 (00011100), make 0
sta PalNum ; sta.b PalNum
inc.b PalNum
jmp Infinity ; bwa hahahahaha jmp Infinity ; bwa hahahahaha
@ -109,17 +111,25 @@ NMIHandler:
rti rti
IRQHandler: IRQHandler:
stz $2121 ;pha
;php
;rep #$31
lda PalNum lda PalNum
;sep #$20
stz $2121
;sta.w $2122
;xba
sta $2122 sta $2122
sta $2122 sta $2122
; lda.w $4211
lda #65 ; lda #65
sta $3000 ; sta $3000
idle: ;idle:
lda $3001 ; lda $3001
; rep #$31
plp
pla
rti rti

View File

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

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

2
snes/monitor/linkfile Normal file
View File

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

306
snes/monitor/main.asm Normal file
View File

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

43
snes/monitor/makefile Normal file
View File

@ -0,0 +1,43 @@
# 65816 stuff
AC = wla-65816
AFLAGS = -o
LD = wlalink
LDFLAGS = -vsr
FL = snesflash
FLFLAGS = -wf
UCON = ucon64
UCONFLAGS = --port=usb --xsnesram
SFILES = main.asm
OFILES = $(SFILES:.asm=.o)
ROMFILE = main.smc
EMU = zsnes
# spc stuff
SPCAC = wla-spc700
SPCSFILES = data/apu/apucode.asm
SPCOFILES = $(SPCSFILES:.asm=.o)
SPCFILE = $(SPCSFILES:.asm=.bin)
all: spc $(OFILES)
$(LD) $(LDFLAGS) linkfile $(ROMFILE)
$(OFILES): $(SFILES)
$(AC) $(AFLAGS) $(SFILES)
spc: $(SPCOFILES)
$(LD) -vsb spclinkfile $(SPCFILE)
$(SPCOFILES): $(SPCSFILES)
$(SPCAC) $(AFLAGS) $(SPCSFILES)
flash:
$(FL) $(FLFLAGS) $(ROMFILE)
upload:
$(UCON) $(UCONFLAGS) $(ROMFILE)
run:
$(EMU) $(ROMFILE)
clean:
rm -f $(ROMFILE) $(SPCFILE) core *~ *.o *.sym *.srm data/apu/*.o data/apu/*.sym

View File

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

View File

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

View File

@ -0,0 +1,272 @@
.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

View File

@ -0,0 +1,255 @@
;*************************************************************************
.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
;*************************************************************************

View File

@ -0,0 +1,975 @@
/*
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

View File

@ -0,0 +1,90 @@
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

View File

@ -0,0 +1,662 @@
;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

View File

@ -0,0 +1,362 @@
/*
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

View File

@ -0,0 +1,126 @@
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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,160 @@
/*
;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

View File

@ -0,0 +1,320 @@
.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

View File

@ -0,0 +1,174 @@
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

View File

@ -0,0 +1,706 @@
/*
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

View File

@ -0,0 +1,530 @@
.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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,94 @@
.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

View File

@ -0,0 +1,20 @@
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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,756 @@
/*
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

View File

@ -0,0 +1,40 @@
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

View File

@ -0,0 +1,34 @@
.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

View File

@ -0,0 +1,74 @@
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:

View File

@ -0,0 +1,15 @@
.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 - atomaniac en rab.bin"
Song0End:
.ends

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
.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
SpritePalette0End:
.ends
.Section "spritetileset 0" superfree
SpriteTileset0:
.incbin "data/cpuusage.pic"
.ends

View File

@ -0,0 +1,648 @@
/*
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

View File

@ -0,0 +1,328 @@
.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

View File

@ -0,0 +1,176 @@
;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

2
snes/monitor/spclinkfile Normal file
View File

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