@nataliapc/mcp-openmsx 1.1.15 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -37
- package/dist/server.js +101 -40
- package/dist/utils.js +42 -2
- package/dist/vectordb.js +61 -0
- package/package.json +8 -3
- package/resources/audio/msx-midi.md +872 -0
- package/resources/audio/psg_registers.md +281 -0
- package/resources/audio/sound_cartridge_scc.md +123 -0
- package/resources/audio/sound_cartridge_scci.md +250 -0
- package/resources/audio/toc.json +8 -4
- package/resources/book--msx2-technical-handbook/toc.json +1 -1
- package/resources/msx-dos/MSX-DOS_2_Environment_Variables.md +1368 -0
- package/resources/msx-dos/MSX-DOS_File_extensions.md +154 -0
- package/resources/msx-dos/toc.json +13 -0
- package/resources/msx-unapi/toc.json +2 -2
- package/resources/others/keyboard_matrices.md +243 -0
- package/resources/others/toc.json +6 -0
- package/resources/programming/asm_callbios.md +79 -0
- package/resources/programming/asm_docopy.md +115 -0
- package/resources/programming/asm_fast_loops.md +200 -0
- package/resources/programming/asm_getslot.md +143 -0
- package/resources/programming/asm_interrupts.md +202 -0
- package/resources/programming/asm_load_screen.md +240 -0
- package/resources/programming/asm_mult_div_shifts.md +487 -0
- package/resources/programming/asm_raminpage1.md +56 -0
- package/resources/programming/asm_vdp_detection.md +78 -0
- package/resources/programming/asm_vdp_routines.md +343 -0
- package/resources/programming/asm_z80_routines_collection.md +810 -0
- package/resources/programming/basic_wiki/ABS().md +36 -0
- package/resources/programming/basic_wiki/AND.md +71 -0
- package/resources/programming/basic_wiki/ASC().md +38 -0
- package/resources/programming/basic_wiki/ATN().md +36 -0
- package/resources/programming/basic_wiki/AUTO.md +39 -0
- package/resources/programming/basic_wiki/BASE().md +147 -0
- package/resources/programming/basic_wiki/BEEP.md +27 -0
- package/resources/programming/basic_wiki/BIN$().md +36 -0
- package/resources/programming/basic_wiki/BLOAD.md +63 -0
- package/resources/programming/basic_wiki/BSAVE.md +61 -0
- package/resources/programming/basic_wiki/CALL.md +391 -0
- package/resources/programming/basic_wiki/CALL_ADJUST.md +40 -0
- package/resources/programming/basic_wiki/CALL_IMPOSE.md +28 -0
- package/resources/programming/basic_wiki/CALL_OPTIONS.md +26 -0
- package/resources/programming/basic_wiki/CALL_PAUSE.md +119 -0
- package/resources/programming/basic_wiki/CALL_PCMPLAY.md +60 -0
- package/resources/programming/basic_wiki/CALL_PCMREC.md +70 -0
- package/resources/programming/basic_wiki/CDBL().md +36 -0
- package/resources/programming/basic_wiki/CHR$().md +51 -0
- package/resources/programming/basic_wiki/CINT().md +36 -0
- package/resources/programming/basic_wiki/CIRCLE.md +51 -0
- package/resources/programming/basic_wiki/CLEAR.md +39 -0
- package/resources/programming/basic_wiki/CLOAD.md +27 -0
- package/resources/programming/basic_wiki/CLOAD?.md +31 -0
- package/resources/programming/basic_wiki/CLOSE.md +44 -0
- package/resources/programming/basic_wiki/CLS.md +51 -0
- package/resources/programming/basic_wiki/COLOR.md +143 -0
- package/resources/programming/basic_wiki/COLOR=.md +93 -0
- package/resources/programming/basic_wiki/COLOR_SPRITE$().md +83 -0
- package/resources/programming/basic_wiki/COLOR_SPRITE().md +85 -0
- package/resources/programming/basic_wiki/CONT.md +23 -0
- package/resources/programming/basic_wiki/COPY.md +215 -0
- package/resources/programming/basic_wiki/COPY_SCREEN.md +61 -0
- package/resources/programming/basic_wiki/COS().md +37 -0
- package/resources/programming/basic_wiki/CSAVE.md +35 -0
- package/resources/programming/basic_wiki/CSNG().md +36 -0
- package/resources/programming/basic_wiki/CSRLIN.md +33 -0
- package/resources/programming/basic_wiki/DATA.md +47 -0
- package/resources/programming/basic_wiki/DEFDBL.md +40 -0
- package/resources/programming/basic_wiki/DEFINT.md +40 -0
- package/resources/programming/basic_wiki/DEFSNG.md +40 -0
- package/resources/programming/basic_wiki/DEFSTR.md +40 -0
- package/resources/programming/basic_wiki/DEF_FN.md +49 -0
- package/resources/programming/basic_wiki/DEF_USR.md +33 -0
- package/resources/programming/basic_wiki/DELETE.md +49 -0
- package/resources/programming/basic_wiki/DIM.md +59 -0
- package/resources/programming/basic_wiki/DRAW.md +77 -0
- package/resources/programming/basic_wiki/ELSE.md +45 -0
- package/resources/programming/basic_wiki/END.md +32 -0
- package/resources/programming/basic_wiki/EOF().md +36 -0
- package/resources/programming/basic_wiki/EQV.md +76 -0
- package/resources/programming/basic_wiki/ERASE.md +35 -0
- package/resources/programming/basic_wiki/ERL.md +34 -0
- package/resources/programming/basic_wiki/ERR.md +143 -0
- package/resources/programming/basic_wiki/ERROR.md +145 -0
- package/resources/programming/basic_wiki/EXP().md +38 -0
- package/resources/programming/basic_wiki/FIELD.md +48 -0
- package/resources/programming/basic_wiki/FIX().md +44 -0
- package/resources/programming/basic_wiki/FN.md +61 -0
- package/resources/programming/basic_wiki/FOR...NEXT.md +80 -0
- package/resources/programming/basic_wiki/FRE().md +66 -0
- package/resources/programming/basic_wiki/GET_DATE.md +60 -0
- package/resources/programming/basic_wiki/GET_TIME.md +34 -0
- package/resources/programming/basic_wiki/GOSUB.md +41 -0
- package/resources/programming/basic_wiki/GOTO.md +41 -0
- package/resources/programming/basic_wiki/HEX$().md +36 -0
- package/resources/programming/basic_wiki/IF...GOTO...ELSE.md +55 -0
- package/resources/programming/basic_wiki/IF...THEN...ELSE.md +50 -0
- package/resources/programming/basic_wiki/IMP.md +83 -0
- package/resources/programming/basic_wiki/INKEY$.md +65 -0
- package/resources/programming/basic_wiki/INP().md +33 -0
- package/resources/programming/basic_wiki/INPUT$().md +51 -0
- package/resources/programming/basic_wiki/INPUT.md +93 -0
- package/resources/programming/basic_wiki/INSTR().md +44 -0
- package/resources/programming/basic_wiki/INT().md +44 -0
- package/resources/programming/basic_wiki/INTERVAL.md +57 -0
- package/resources/programming/basic_wiki/KEY().md +51 -0
- package/resources/programming/basic_wiki/KEY.md +254 -0
- package/resources/programming/basic_wiki/LEFT$().md +39 -0
- package/resources/programming/basic_wiki/LEN().md +36 -0
- package/resources/programming/basic_wiki/LET.md +68 -0
- package/resources/programming/basic_wiki/LINE.md +74 -0
- package/resources/programming/basic_wiki/LINE_INPUT.md +79 -0
- package/resources/programming/basic_wiki/LIST.md +58 -0
- package/resources/programming/basic_wiki/LLIST.md +43 -0
- package/resources/programming/basic_wiki/LOAD.md +56 -0
- package/resources/programming/basic_wiki/LOCATE.md +67 -0
- package/resources/programming/basic_wiki/LOG().md +36 -0
- package/resources/programming/basic_wiki/LPOS().md +31 -0
- package/resources/programming/basic_wiki/LPRINT.md +46 -0
- package/resources/programming/basic_wiki/MAXFILES.md +39 -0
- package/resources/programming/basic_wiki/MERGE.md +54 -0
- package/resources/programming/basic_wiki/MID$().md +72 -0
- package/resources/programming/basic_wiki/MOD.md +39 -0
- package/resources/programming/basic_wiki/MOTOR.md +46 -0
- package/resources/programming/basic_wiki/NEW.md +27 -0
- package/resources/programming/basic_wiki/NOT.md +61 -0
- package/resources/programming/basic_wiki/OCT$().md +36 -0
- package/resources/programming/basic_wiki/ON...GOSUB.md +45 -0
- package/resources/programming/basic_wiki/ON...GOTO.md +42 -0
- package/resources/programming/basic_wiki/ON_ERROR_GOTO.md +61 -0
- package/resources/programming/basic_wiki/ON_INTERVAL_GOSUB.md +54 -0
- package/resources/programming/basic_wiki/ON_KEY_GOSUB.md +56 -0
- package/resources/programming/basic_wiki/ON_SPRITE_GOSUB.md +41 -0
- package/resources/programming/basic_wiki/ON_STOP_GOSUB.md +56 -0
- package/resources/programming/basic_wiki/ON_STRIG_GOSUB.md +70 -0
- package/resources/programming/basic_wiki/OPEN.md +103 -0
- package/resources/programming/basic_wiki/OR.md +75 -0
- package/resources/programming/basic_wiki/OUT.md +35 -0
- package/resources/programming/basic_wiki/PAD().md +110 -0
- package/resources/programming/basic_wiki/PAINT.md +66 -0
- package/resources/programming/basic_wiki/PDL().md +53 -0
- package/resources/programming/basic_wiki/PEEK().md +44 -0
- package/resources/programming/basic_wiki/PLAY().md +58 -0
- package/resources/programming/basic_wiki/PLAY.md +196 -0
- package/resources/programming/basic_wiki/POINT.md +52 -0
- package/resources/programming/basic_wiki/POKE.md +51 -0
- package/resources/programming/basic_wiki/POS().md +36 -0
- package/resources/programming/basic_wiki/PRESET.md +61 -0
- package/resources/programming/basic_wiki/PRINT.md +179 -0
- package/resources/programming/basic_wiki/PSET.md +82 -0
- package/resources/programming/basic_wiki/PUT_KANJI.md +93 -0
- package/resources/programming/basic_wiki/PUT_SPRITE.md +143 -0
- package/resources/programming/basic_wiki/READ.md +45 -0
- package/resources/programming/basic_wiki/REM.md +42 -0
- package/resources/programming/basic_wiki/RENUM.md +78 -0
- package/resources/programming/basic_wiki/RESTORE.md +52 -0
- package/resources/programming/basic_wiki/RESUME.md +45 -0
- package/resources/programming/basic_wiki/RETURN.md +47 -0
- package/resources/programming/basic_wiki/RIGHT$().md +39 -0
- package/resources/programming/basic_wiki/RND().md +51 -0
- package/resources/programming/basic_wiki/RUN.md +56 -0
- package/resources/programming/basic_wiki/SAVE.md +65 -0
- package/resources/programming/basic_wiki/SCREEN.md +164 -0
- package/resources/programming/basic_wiki/SET_ADJUST.md +66 -0
- package/resources/programming/basic_wiki/SET_BEEP.md +76 -0
- package/resources/programming/basic_wiki/SET_DATE.md +103 -0
- package/resources/programming/basic_wiki/SET_PAGE.md +52 -0
- package/resources/programming/basic_wiki/SET_PASSWORD.md +75 -0
- package/resources/programming/basic_wiki/SET_PROMPT.md +61 -0
- package/resources/programming/basic_wiki/SET_SCREEN.md +100 -0
- package/resources/programming/basic_wiki/SET_SCROLL.md +55 -0
- package/resources/programming/basic_wiki/SET_TIME.md +83 -0
- package/resources/programming/basic_wiki/SET_TITLE.md +87 -0
- package/resources/programming/basic_wiki/SET_VIDEO.md +49 -0
- package/resources/programming/basic_wiki/SGN().md +38 -0
- package/resources/programming/basic_wiki/SIN().md +36 -0
- package/resources/programming/basic_wiki/SOUND.md +188 -0
- package/resources/programming/basic_wiki/SPACE$().md +38 -0
- package/resources/programming/basic_wiki/SPC().md +34 -0
- package/resources/programming/basic_wiki/SPRITE$().md +50 -0
- package/resources/programming/basic_wiki/SPRITE.md +31 -0
- package/resources/programming/basic_wiki/SQR().md +32 -0
- package/resources/programming/basic_wiki/STICK().md +70 -0
- package/resources/programming/basic_wiki/STOP.md +70 -0
- package/resources/programming/basic_wiki/STR$().md +37 -0
- package/resources/programming/basic_wiki/STRIG().md +82 -0
- package/resources/programming/basic_wiki/STRING$().md +42 -0
- package/resources/programming/basic_wiki/SWAP.md +62 -0
- package/resources/programming/basic_wiki/TAB().md +38 -0
- package/resources/programming/basic_wiki/TAN().md +36 -0
- package/resources/programming/basic_wiki/TIME.md +59 -0
- package/resources/programming/basic_wiki/TROFF.md +21 -0
- package/resources/programming/basic_wiki/TRON.md +39 -0
- package/resources/programming/basic_wiki/USR().md +66 -0
- package/resources/programming/basic_wiki/VAL().md +36 -0
- package/resources/programming/basic_wiki/VARPTR().md +50 -0
- package/resources/programming/basic_wiki/VDP().md +103 -0
- package/resources/programming/basic_wiki/VPEEK().md +46 -0
- package/resources/programming/basic_wiki/VPOKE.md +48 -0
- package/resources/programming/basic_wiki/WAIT.md +38 -0
- package/resources/programming/basic_wiki/WIDTH.md +76 -0
- package/resources/programming/basic_wiki/XOR.md +72 -0
- package/resources/programming/basic_wiki/_toc.json +871 -0
- package/resources/programming/dos_error_handling.md +85 -0
- package/resources/programming/toc.json +51 -36
- package/resources/programming/vdp_commands_speed.md +147 -0
- package/resources/programming/vdp_programming_faq.md +55 -0
- package/resources/programming/vdp_programming_tutorial.md +390 -0
- package/resources/programming/vdp_screensplit_programming_guide.md +166 -0
- package/resources/programming/vdp_scrolling_on_msx.md +124 -0
- package/resources/programming/vdp_the_yjk_screen_modes.md +227 -0
- package/resources/programming/vdp_v9938_vram_timings.md +539 -0
- package/resources/programming/vdp_v9938_vram_timings_part_2.md +281 -0
- package/resources/sdcc/toc.json +1 -1
- package/vector-db/index.json +1 -0
- /package/resources/msx-unapi/{Ethernet_UNAPI_specification_1.1.md → Ethernet_UNAPI_specification_1_1.md} +0 -0
- /package/resources/msx-unapi/{MSX_UNAPI_specification_1.1.md → MSX_UNAPI_specification_1_1.md} +0 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Load graphic data into the VRAM
|
|
2
|
+
|
|
3
|
+
Here is an couple of routine which can load a screen from disk into the VRAM. The routines are oriented towards MSX-DOS 2, if you want it to use DOS 1 you will have to change the disk load routines, aswell as the error abort routine. Also, they are programmed in Compass, so it they probably won’t directly compile in another assembler because of certain differences like hex notation and label length and such, but it should be easy to adapt.
|
|
4
|
+
|
|
5
|
+
First, I’ll give an example of how the LoadScreen routine should be called:
|
|
6
|
+
|
|
7
|
+
```assembly
|
|
8
|
+
;
|
|
9
|
+
; Load screen FILENAME at #18000 (page 3 in screen 5)
|
|
10
|
+
;
|
|
11
|
+
Start: ld de,FILENAME
|
|
12
|
+
ld a,1
|
|
13
|
+
ld hl,#8000
|
|
14
|
+
call LoadScreen
|
|
15
|
+
ret
|
|
16
|
+
|
|
17
|
+
FILENAME: DB "IMAGE.SC5",0
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Load a file into the VRAM
|
|
21
|
+
|
|
22
|
+
Following are the actual routines. I’ll explain a bit inbetween, but if you want to use them in your own routines, just copy and paste a little, and either delete or comment the inbetween explanation parts.
|
|
23
|
+
|
|
24
|
+
First of all, some definitions are made. I go by the book, and the book is called MSX-DOS 2 in this case. These are the official naming conventions, so ah, why not just use them. Also, the temporary area is defined here. You can place it anywhere you want, and change the size to whatever value you want (clearly, larger values give better results) by modifying the given constants.
|
|
25
|
+
|
|
26
|
+
```assembly
|
|
27
|
+
;
|
|
28
|
+
;=================================================================
|
|
29
|
+
;= Graphic loaders ===============================================
|
|
30
|
+
;=================================================================
|
|
31
|
+
;
|
|
32
|
+
;Definitions
|
|
33
|
+
;
|
|
34
|
+
Bdos: equ 5
|
|
35
|
+
_TERM0: equ #00 ;. program terminate
|
|
36
|
+
_STROUT: equ #09 ;. string output
|
|
37
|
+
_OPEN: equ #43 ;. open file handle
|
|
38
|
+
_CLOSE: equ #45 ;. close file handle
|
|
39
|
+
_READ: equ #48 ;. read from file handle
|
|
40
|
+
_SEEK: equ #4A ;. move file handle pointer
|
|
41
|
+
_TERM: equ #62 ;. terminate with error code
|
|
42
|
+
.EOF: equ #C7 ;. EOF error
|
|
43
|
+
|
|
44
|
+
TEMP1: equ #4000 ;start address temporary space
|
|
45
|
+
TEMP1_SIZE: equ #4000 ;size of temporary space
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Following is the routine that loads the entire file into the VRAM. This means it keeps on reading bytes and sending it to the VRAM until DOS returns a .EOF ‘End Of File’ error. The first part is the initializer, which a. sets the VDP’s VRAM Write start address by calling the SetVDP_Write routine (for details about that, see below), b. opens the file, and c. (optionally) skips the first 7 bytes of the file. Here I say optionally, because I actually left that part commented out, since I myself don’t use files in the BSAVE format (I convert all files to the pure VRAM contents) (so I’ve also got a separate palette).
|
|
49
|
+
|
|
50
|
+
```assembly
|
|
51
|
+
;
|
|
52
|
+
;Load the entire file into the VRAM
|
|
53
|
+
;
|
|
54
|
+
;DE = filenamenaam
|
|
55
|
+
;AHL = VRAM start address
|
|
56
|
+
;
|
|
57
|
+
Load_Screen: call SetVdp_Write
|
|
58
|
+
ld c,_OPEN
|
|
59
|
+
xor a ;no flags
|
|
60
|
+
call Bdos
|
|
61
|
+
jp nz,Error
|
|
62
|
+
ld a,b ;Put the file handle
|
|
63
|
+
ld (LS_FHANDLE),a ; into the ld b,0 instruction
|
|
64
|
+
|
|
65
|
+
; ld de,0 ;Move file handle pointer to 7th byte
|
|
66
|
+
; ld hl,7
|
|
67
|
+
; xor a
|
|
68
|
+
; ld c,_SEEK
|
|
69
|
+
; call Bdos
|
|
70
|
+
; jp nz,Error
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This next part actually loads the file from disk. The file handle was put directly inside the LD B,n instruction register by the previous piece of code, which is a little faster. Note that in this case, when loading files from a physical medium, a few extra T-states don’t *really* matter, and it’s actually better to use a more ‘tidy’ solution. But, I like self-modifying code, so alas, I couldn’t resist.
|
|
74
|
+
|
|
75
|
+
```assembly
|
|
76
|
+
LoadScr_Loop: ld hl,TEMP1_SIZE
|
|
77
|
+
ld de,TEMP1
|
|
78
|
+
ld b,0 ;self-modifying
|
|
79
|
+
LS_FHANDLE: equ $-1
|
|
80
|
+
ld c,_READ
|
|
81
|
+
call Bdos ;Read temp1_size bytes
|
|
82
|
+
cp .EOF ; check if end of file,
|
|
83
|
+
jp z,LoadScr_End ; if so, done!
|
|
84
|
+
and a
|
|
85
|
+
jp nz,Error
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Now comes the (somewhat) neat part. This is the part that actually sends the data from the buffer to the VRAM. Now, in this case even single T-States *DO* matter, because this concerns a loop which is called numerous times. So, this part is highly optimized using techniques from my ‘Fast Loops’ article.
|
|
89
|
+
|
|
90
|
+
```assembly
|
|
91
|
+
dec hl ;Use "Mystery Fast Loop Calculus"
|
|
92
|
+
ld b,l ;(result: loop HL (=nr of bytes read) times)
|
|
93
|
+
inc b
|
|
94
|
+
ld a,h
|
|
95
|
+
inc a
|
|
96
|
+
ld c,#98
|
|
97
|
+
ld hl,TEMP1
|
|
98
|
+
LoadScr_LdLp: otir
|
|
99
|
+
dec a
|
|
100
|
+
jp nz,LoadScr_LdLp
|
|
101
|
+
jp LoadScr_Loop
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
And finally, the end of the routine. This part is jumped to when an .EOF is returned by the disk read routines, meaning the end of the file has been reached. Commented out is a part which also sets the stored palette (for BSAVE format files, see the separate palette file loader for more info on that), and after that the file is closed.
|
|
105
|
+
|
|
106
|
+
```assembly
|
|
107
|
+
LoadScr_End:
|
|
108
|
+
; ld de,0 ;Move file handle pointer
|
|
109
|
+
; ld hl,#7680 + 7 ; to palette start address
|
|
110
|
+
; ld a,(LS_FHANDLE)
|
|
111
|
+
; ld b,a
|
|
112
|
+
; xor a
|
|
113
|
+
; ld c,_SEEK
|
|
114
|
+
; call Bdos
|
|
115
|
+
; jp nz,Error
|
|
116
|
+
; ld hl,32
|
|
117
|
+
; ld de,TEMP1
|
|
118
|
+
; ld a,(LS_FHANDLE)
|
|
119
|
+
; ld b,a
|
|
120
|
+
; ld c,_READ ;Read From File Handle
|
|
121
|
+
; call Bdos
|
|
122
|
+
; jp nz,Error
|
|
123
|
+
; ld hl,TEMP1
|
|
124
|
+
; call SetPalet
|
|
125
|
+
|
|
126
|
+
ld a,(LS_FHANDLE)
|
|
127
|
+
ld b,a
|
|
128
|
+
ld c,_CLOSE ;Close File Handle
|
|
129
|
+
call Bdos
|
|
130
|
+
jp nz,Error
|
|
131
|
+
ret
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Last, there’s also the error handling routine, which exits to dos with the appropriate error message.
|
|
135
|
+
|
|
136
|
+
```assembly
|
|
137
|
+
;
|
|
138
|
+
;Handle an error...
|
|
139
|
+
;Returns to DOS 2 which will show the error.
|
|
140
|
+
;
|
|
141
|
+
Error:
|
|
142
|
+
ld b,a
|
|
143
|
+
ld c,_TERM
|
|
144
|
+
jp Bdos
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Load and set a palette
|
|
148
|
+
|
|
149
|
+
This routine loads a file from disk, which should be 32 bytes in size, and contains the palette, stored in the same format as the VDP uses (also the same format Basic stores at address #7680). Basically it doesn’t do much interesting - just loads the data into the temporary buffer, then calls a function which sets that palette.
|
|
150
|
+
|
|
151
|
+
```assembly
|
|
152
|
+
;
|
|
153
|
+
;Load palette file
|
|
154
|
+
;
|
|
155
|
+
;DE = filename
|
|
156
|
+
;
|
|
157
|
+
Load_Palet: ld c,_OPEN ;Open File Handle (no flags)
|
|
158
|
+
xor a
|
|
159
|
+
call Bdos
|
|
160
|
+
jp nz,Error
|
|
161
|
+
push bc
|
|
162
|
+
ld de,TEMP1
|
|
163
|
+
ld hl,32
|
|
164
|
+
ld c,_READ ;Read From File Handle
|
|
165
|
+
call Bdos
|
|
166
|
+
jp nz,Error
|
|
167
|
+
pop bc
|
|
168
|
+
ld c,_CLOSE ;Close File Handle
|
|
169
|
+
call Bdos
|
|
170
|
+
jp nz,Error
|
|
171
|
+
ld hl,TEMP1 ;Set palette
|
|
172
|
+
jp SetPalet
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## The VDP routines
|
|
176
|
+
|
|
177
|
+
The following routines are the VDP routines which are called from the Load functions. The first sets the start address of the VDP VRAM I/O port (port #98) to the specified value in registers A:HL (where bit 0 of register A contains bit 17 of the address).
|
|
178
|
+
|
|
179
|
+
```assembly
|
|
180
|
+
;
|
|
181
|
+
;
|
|
182
|
+
;=================================================================
|
|
183
|
+
;= VDP-Routines ==================================================
|
|
184
|
+
;=================================================================
|
|
185
|
+
;
|
|
186
|
+
;
|
|
187
|
+
;Set VDP port #98 to start writing from address AHL (17-bit)
|
|
188
|
+
;
|
|
189
|
+
SetVdp_Write: rlc h
|
|
190
|
+
rla
|
|
191
|
+
rlc h
|
|
192
|
+
rla
|
|
193
|
+
srl h
|
|
194
|
+
srl h
|
|
195
|
+
di
|
|
196
|
+
out (#99),a ;set bits 15-17
|
|
197
|
+
ld a,14+128
|
|
198
|
+
out (#99),a
|
|
199
|
+
ld a,l ;set bits 0-7
|
|
200
|
+
nop
|
|
201
|
+
out (#99),a
|
|
202
|
+
ld a,h ;set bits 8-14
|
|
203
|
+
or 64 ; + write access
|
|
204
|
+
ei
|
|
205
|
+
out (#99),a
|
|
206
|
+
ret
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
And second, there’s the routine which sends a new palette to the VDP, which is read from address HL. You might notice the huge lot of DW #A3EDs... Those are actually 32 OUTI instructions. I use this notition because it is much more compact than writing 32 lines with OUTIs. Ofcouse you could also use an OTIR instruction, however OUTI is about 25% faster than OTIR.
|
|
210
|
+
|
|
211
|
+
```assembly
|
|
212
|
+
;
|
|
213
|
+
;Set the VDP's palette to the palette HL points to
|
|
214
|
+
;Changes: AF, BC, HL (=updated)
|
|
215
|
+
;
|
|
216
|
+
SetPalet: xor a ;Set p#pointer to zero.
|
|
217
|
+
di
|
|
218
|
+
out (#99),a
|
|
219
|
+
ld a,16+128
|
|
220
|
+
ei
|
|
221
|
+
out (#99),a
|
|
222
|
+
ld c,#9A
|
|
223
|
+
DW #A3ED,#A3ED,#A3ED,#A3ED ;32x OUTI instruction
|
|
224
|
+
DW #A3ED,#A3ED,#A3ED,#A3ED ; (faster than OTIR)
|
|
225
|
+
DW #A3ED,#A3ED,#A3ED,#A3ED
|
|
226
|
+
DW #A3ED,#A3ED,#A3ED,#A3ED
|
|
227
|
+
DW #A3ED,#A3ED,#A3ED,#A3ED
|
|
228
|
+
DW #A3ED,#A3ED,#A3ED,#A3ED
|
|
229
|
+
DW #A3ED,#A3ED,#A3ED,#A3ED
|
|
230
|
+
DW #A3ED,#A3ED,#A3ED,#A3ED
|
|
231
|
+
ret
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Well, we’re done. I hope it’s been of any use to you! Greetings, earthling!
|
|
235
|
+
|
|
236
|
+
~~Grauw
|
|
237
|
+
|
|
238
|
+
## Source
|
|
239
|
+
|
|
240
|
+
https://map.grauw.nl/sources/load_screen.php
|