Hi there,
I have produced the following (hopefully understandable) code so far for Koen's request of a fade routine:
Code:
10 REM Fade Routines v0.9 (24th Sept. 2008)
20 REM by Francis G. Loch
30
40 DIM code% 512
50 osword%=&FFF1
60 osbyte%=&FFF4
70
80 REM Read fade table
90
100 RESTORE 980
110 FOR I%=0 TO 97
120 READ value%
130 code%?(I%+12)=value%
140 NEXT
150
160 FOR opt%=0 TO 3 STEP 3
170 P%=code%+110
180
190[OPT opt%
200
210 \ Initialise
220
230.initfade JSR readpal
240 JSR palblack
250 RTS
260
270 \ Read palette information
280
290.readpal LDX #0
300 STX code%
310.rp_loop LDA #&0B
320 LDX #code% MOD 256
330 LDY #code% DIV 256
340 JSR osword%
350 LDA code%+1
360.storepal STA code%+5
370 LDX storepal+1
380 INX
390 STX storepal+1
400 BNE counter
410 LDX storepal+2
420 INX
430 STX storepal+2
440.counter LDX code%
450 INX
460 STX code%
470 CPX #4
480 BNE rp_loop
490
500 \ Change modified code back to original
510
520 LDA #code% MOD 256
530 STA storepal+1
540 LDA #code% DIV 256
550 STA storepal+2
560 RTS
570
580 \ Set all colours to black
590
600.palblack LDX #0
610 STX code%
620 STX code%+1
630 STX code%+2
640 STX code%+3
650 STX code%+4
660.pb_loop LDA #&0C
670 LDX #code% MOD 256
680 LDY #code% DIV 256
690 JSR osword%
700 LDX code%
710 INX
720 STX code%
730 CPX #4
740 BNE pb_loop
750 RTS
760
770 \ Wait for vertical blank
780
790.waitvbl LDA #&13
800 JSR osbyte%
810 RTS
820
830 \ Fade in routine
840
850.fadein
860 RTS
870
880 \ Fade out routine
890
900.fadeout
910 RTS
920
930]
940 NEXT
950
960 REM Colour fade tables
970
980 DATA 0,0,0,0,4,4,4,4,4,4,4,4,4,1
990 DATA 0,4,4,4,4,4,1,1,1,5,5,5,5,2
1000 DATA 4,4,4,1,1,5,5,5,2,2,6,6,6,3
1010 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,4
1020 DATA 0,0,0,4,4,4,4,4,4,1,1,1,1,5
1030 DATA 0,4,4,4,4,1,1,5,5,5,5,2,2,6
1040 DATA 4,4,4,1,1,5,5,2,2,6,6,6,3,7
1050
1060 PRINT "Code base = &";~code%
1070 PRINT "'initfade' offset = &";~(initfade-code%);" (&";~initfade;")"
1080 PRINT "'fadein' offset = &";~(fadein-code%);" (&";~fadein;")"
1090 PRINT "'fadeout' offset = &";~(fadeout-code%);" (&";~fadeout;")"
At the moment I am using the initial memory space allocated by
code% for storage of the palette information and colour fade tables.
My problem is that I am kind of stuck on how to relate the stored palette information to the appropriate section of the colour fade table and use these for the fade in and fade out routines.
Kind regards,
Francis.
EDIT: Corrected the colour fade table as I had it in the wrong order.
