Thanks to Julio Marchi for this space in MSX All
 

SLOT View


SLOT View 1.0
Source code


1. Program description
  How Slot View works

  The memory visualization may looks a quite simple task, but, in fact, it is more challenging than it seems. These challenges are related to the following program issues:
  • The program is located at the page 2 of the RAM;
  • Some BIOS calls are performed. The BIOS is located at the page 0 of the MSX ROM;
  • The operation system uses the page 3 of the RAM;
  • Nevertheless, page 1 is free for use.
  The slots (or sublots) mentioned above are in use and they cannot be changed before some caution is taken. These slots will be referred as "problem subslots".
  One of the adopted strategies to solve the problem is to copy the memory content located at the pages 0, 2 and 3 to the page 1 of the RAM, as seen on figure 1.


Figure 1 - Copy

  When the RAM is expended, a new strategy for the RAM slot must comes up. The RAM subslots located on the pages 0, 2 and 3 must be copied to the page 1 of the RAM, due to the fact of changing the "problem slots".
  See on figure 2 the "problem slots" marked with red color. The MSX ROM is always on subslot 0-0. Thus, the RAM location depends on the MSX model. Let's assume that RAM is located at subslot 2-0. By observing the figure 2, it is clear to understand the problem of accessing the subslots located on pages 2 and 3 of the RAM.


Figura 2 - Subslots scheme

  When the program has to access another subslot on the page 2, the contact with the program is lost. To solve this problem, there is a copy routine located on the page 3 of the RAM. In that case, every time that an access to the page 2 is required, the program jumps to this routine at page 3, which is responsible for:
  • Change page 2 subslot;
  • Perform the copy from page 2 to page 1 of the RAM;
  • Return to original configuration on page 2; and
  • Return the control to the main program at page 2.

  Layout

Start Address Final Address Size Name Function Status
8D57 8D81 002A recctx Recover context from slots. Ok
8D82 8DD0 004E salctx Save context from slots. OK
8DD1 8E44 0074 copyslot Copy slot to RAM page (page 2). OK
8E45 8FFF 01BA tela Main screen compressed using Run-Length. Ok
9000 9017 0017 view-t Extract and print main screen. Ok
9018 909A 0082 dump2 Print memory data. Ok
909B 9144 00A9 bloco Print some extra data. Ok
9145 922F 00EB mudaslt Chage the slot and the subslot. OK
      savepg Savee current page on disk. Missing
9230 93C6 0196 main Main program. Beta

Main program:
* Extract and print the main screen
* Set the following memory configuration (port &HA8): RAM RAM RAM ROM
* Page = 0
* Slot = 0
* Subslot = 0
* Address = 0
* Block = 0
* Update info
* Dump

Variables:
B000 - Original slot configuration
B001 - Current page
B002 - Current slot
B003 - Current subslot
B004 - address+offset
B005 - address+offset
B006 - Block
B007 - RAM slot (value from 0 to 3)
B008 - Subslots 0
B009 - Subslots 1
B00A - Subslots 2
B00B - Subslots 3
B00C - RAM Subslots

C000 - Area on page 3 reserved to receive a copy of "copyslot" routine


Tests

Slots access (MSX Turbo R):

  Page 0 Page 1 Page 2 Page 3
Slot 0-0 Ok Ok Ok Ok
Slot 0-1 Ok Ok Ok Ok
Slot 0-2 Ok Ok Ok Ok
Slot 0-3 Ok Ok Ok Ok
Slot 1-0 Ok Ok Ok Ok
Slot 1-1 Ok Ok Ok Ok
Slot 1-2 Ok Ok Ok Ok
Slot 1-3 Ok Ok Ok Ok
Slot 2-0 Ok Ok Ok Ok
Slot 2-1 Ok Ok Ok Ok
Slot 2-2 Ok Ok Ok Ok
Slot 2-3 Ok Ok Ok Ok
Slot 3-0 Ok Ok Ok Ok
Slot 3-1 Ok Ok Ok Ok
Slot 3-2 Ok Ok Ok Ok
Slot 3-3 Ok Ok Ok Ok

  The MSX Turbo-R tested RAM was located at slot 3-0.


2. Source code
  Note: the code marked as blue indicates the changes from the previous version.

recctx
   10 		ORG  &H8D57
   20 		IN   A,(&HA8)
   30 		LD   HL,&HB00B
   40 		LD   D,A
   50 		LD   A,&B00111111
   60 		AND  D
   70 		LD   C,A
   80 		LD   B,4
   90 		DI 
  100 LOOP:	LD   A,B
  110 		DEC  A
  120 		SLA  A
  130 		SLA  A
  140 		SLA  A
  150 		SLA  A
  160 		SLA  A
  170 		SLA  A
  180 		ADD  A,C
  190 		OUT  (&HA8),A
  200 		LD   A,(HL)
  210 		DEC  HL
  220 		CPL 
  230 		LD   (&HFFFF),A
  240 		DJNZ LOOP
  250 		LD   A,D
  260 		OUT  (&HA8),A
  270 		EI 
  280 		RET

salctx
   10 		ORG  &H8D82
   20 		IN   A,(&HA8)
   30 		LD   HL,&HB00C
   40 		LD   D,A
   50 		LD   A,&B00111111
   60 		AND  D
   70 		LD   C,A
   80 		LD   B,4
   90 		DI 
  100 LOOP:	LD   A,B		; Copy slots info
  110 		DEC  A			; to variables
  120 		SLA  A
  130 		SLA  A
  140 		SLA  A
  150 		SLA  A
  160 		SLA  A
  170 		SLA  A
  180 		ADD  A,C
  190 		OUT  (&HA8),A
  200 		LD   A,(&HFFFF)
  210 		DEC  HL
  220 		LD   (HL),A
  230 		DJNZ LOOP
  240 		LD   A,D
  250 		OUT  (&HA8),A
  260 		LD   B,&B00110000
  270 		AND  B
  280 		SRL  A
  290 		SRL  A
  300 		SRL  A
  310 		SRL  A
  320 		LD   (&HB007),A		; Indicate the RAM slot
  330 		LD   A,(&HFFFF)
  340 		LD   C,&B11110000
  350 		AND  C
  360 		LD   C,A
  370 		SRL  A
  380 		SRL  A
  390 		SRL  A
  400 		SRL  A
  410 		ADD  A,C
  420 		CPL 
  430 		LD   (&HFFFF),A		; Set RAM slot to RAM RAM RAM RAM
  435		LD   (&HB00C),A		; Save variable
  440 		EI 
  450 		RET 

copyslot
   10 		ORG  &H8DD1
   50 		LD   DE,(&HB004)	; Address of copy
   60 		LD   HL,&HB002		; Configure SLOT
   70 		LD   C,(HL)
   80 		LD   HL,&HB001
   90 		LD   B,(HL)		; Load current page
  100 		XOR  A
  110 		CP   B
  120 		LD   A,&B00000011	; If page is 0
  130 		JR   Z,SLT0
  140 		SLA  C
  150 		SLA  C
  160 		SLA  C
  170 		SLA  C
  171 		LD   A,(&HB007)
  172 		LD   B,A
  173 		LD   A,(&HB002)
  174 		CP   B
  175 		JR   NZ,PGII		; If slot is not RAM, go to PGII
  176 SLRAM:	LD   A,(&HB00C)
  177 		LD   (&HC200),A
  178 		LD   C,A
  179 		LD   A,&B11001111
  180 		AND  C
  181 		LD   B,A
  182 		LD   A,(&HB003)
  183 		SLA  A
  184 		SLA  A
  185 		SLA  A
  186 		SLA  A
  187 		ADD  A,B
  188 		LD   (&HFFFF),A
  189 		LD   C,1
  190 		LD   HL,&H4000
  191		LD   DE,&H8000
  192 		JR   LOOP		; "JR" necessary - code replication at C000 
  198 PGII:	LD   A,&B00110000	; If page 2
  199 SLT0:	LD   HL,&HB000
  200 		LD   B,(HL)
  210 		CPL 
  220 		AND  B
  230 		ADD  A,C
  240 		OUT  (&HA8),A
  245 		LD   C,0		; Indicates that it is not RAM+PG2
  250 		LD   HL,&H4000
  260 LOOP:	LD   A,(DE)
  270 		LD   (HL),A
  280 		INC  HL
  290 		INC  DE
  300 		XOR  A
  310 		CP   L
  320 		JR   NZ,LOOP
  330 		LD   A,&H80
  340 		CP   H
  350 		JR   NZ,LOOP
  351 		XOR  A
  352 		CP   C
  353 		JR   Z,FIM
  354 		LD   A,(&HC200)
  355 		LD   (&HFFFF),A
  356 		RET 
  370 FIM:	LD   A,B
  380 		OUT  (&HA8),A
  390 		RET 

view-t
   10 		ORG  &H9000
   20 		LD   DE,&H8E45		; Address of compressed screen
   25 		LD   HL,0
   30 INICIO:	LD   A,(DE)
   40 		OR   0
   50 		JR   Z,FIM
   60 		LD   B,A
   70 		INC  DE
   80 		LD   A,(DE)
   90 LOOP:     CALL &H004D
  100 		INC  HL
  120 		DJNZ LOOP
  130 		INC  DE
  140 		JR   INICIO
  150 FIM:	RET 

dump2
   10 		ORG  &H9018
   11 		LD   DE,(&HB004)	; Memory position
   12 		CALL TESTE		; Test to adjust to &H4000
   30 		LD   HL,268		; Initial position of text
   40 		EXX 			; Chage registers
   50 		LD   B,16		; 16 text lines
   60 		LD   HL,242		; Hexadecimal inital position
   70 LE:	EXX 			; Change back registers
   80 		LD   B,8
   90 LI:	LD   A,(DE)
  100 		LD   C,A
  110 		CP   33			; Start to print text
  120 		JP   C,DOT
  130 		CP   127
  140 		JR   C,NDOT
  150 DOT:	LD   A,46
  160 NDOT:	CALL &H004D
  170 		INC  DE
  180 		INC  HL			; End of print
  190 		LD   A,C
  200 		EXX 			; Change registers
  210 		LD   C,A
  220 		AND  &B11110000		; Start hexadecimal print
  230 		SRL  A
  240 		SRL  A
  250 		SRL  A
  260 		SRL  A
  270 		CP   10
  280 		JR   C,NUM1
  290 		ADD  A,7
  300 NUM1:	ADD  A,48
  310 		CALL &H004D
  320 		LD   A,C
  330 		AND  &B00001111
  340 		CP   10
  350 		JR   C,NUM2
  360 		ADD  A,7
  370 NUM2:	ADD  A,48
  380 		INC  HL
  390 		CALL &H004D
  400 		INC  HL
  410 		INC  HL			; End of hexadecimal print
  420 		EXX 			; Change back registers
  430 		DJNZ LI
  440 		EXX 			; Change registers
  450 		LD   DE,16		; Next hexadecimal line
  460 		ADD  HL,DE
  470 		EXX 			; Change back registers
  480 		PUSH DE
  490 		LD   DE,32
  500 		ADD  HL,DE
  510 		POP  DE
  520 		EXX 			; Change registers
  530 		DJNZ LE
  540 		EXX 			; Change back registers
  550 		RET 
  560 TESTE:	LD   HL,&HB001
  570 		LD   A,(HL)
  571 		LD   B,1		; Check if page is 1
  572 		CP B
  573 		RET Z			; Return if true
  580 		LD   B,0
  590 		CP   B
  591 		JR   NZ,AK2
  592 		LD   HL,&H4000		; If page is 0, add 4000 to address
  593 AK1:	ADD  HL,DE		; Fix address topage 1
  594 		LD   D,H
  595 		LD   E,L
  596 		RET 
  600 AK2:	LD   HL,&HC000		; If page is 2, add C000 to address
  610 		LD   B,2
  620 		CP   B
  630 		JR   Z,AK1
  640 		LD HL,&H8000		; If page is 3, add 8000 to address
  650		JR AK1

bloco
   10 		ORG  &H909B
   20 		LD   HL,&HB006		; Print current block
   30 		LD   A,(HL)
   40 		LD   D,0
   50 		LD   E,A
   60 		LD   HL,168
   70 		CALL END
   80 		JR   E2
   90 END:	LD   A,E
  100 		SRL  A
  110 		SRL  A
  120 		SRL  A
  130 		SRL  A
  140 		CALL ASCII
  150 		CALL &H004D
  160 END2:	LD   A,E
  170 		AND  &B00001111
  180 		CALL ASCII
  190 		INC  HL
  200 		CALL &H004D
  210 		RET 
  220 ASCII:	CP   10
  230 		JR   C,NUM1
  240 		ADD  A,7
  250 NUM1:	ADD  A,48
  260 		RET 
  270 E2:	LD   DE,(&HB004)	; Print current address
  330 		LD   HL,127
  340 		ADD  HL,DE
  350 		LD   B,H
  360 		LD   C,L
  370 		LD   HL,178
  380 		CALL END
  390 		LD   HL,176
  400 		LD   E,D
  410 		CALL END
  420 		LD   D,B
  430 		LD   E,C
  440 		LD   HL,183
  450 		CALL END
  460 		LD   HL,181
  470 		LD   E,D
  480 		CALL END
  490 		LD   HL,&HB002		; Print current slot
  500 		LD   A,(HL)
  510 		LD   E,A
  520 		LD   HL,86
  530 		CALL END2
  540 		LD   HL,&HB003		; Print current subslot
  550 		LD   A,(HL)
  560 		LD   E,A
  570 		LD   HL,88
  580 		CALL END2
  590 		LD   HL,&HB001		; Print current page
  600 		LD   A,(HL)		; and the limits (?000-?FFF)
  610 		LD   B,A
  620 		XOR  A
  630 		CP   B
  640 		JR   NZ,P1
  650 		LD   DE,&H0003
  660 		JR   PP
  670 P1:	LD   A,1
  680 		CP   B
  690 		JR   NZ,P2
  700 		LD   DE,&H0407
  710 		JR   PP
  720 P2:	LD   A,2
  730 		CP   B
  740 		JR   NZ,P3
  750 		LD   DE,&H080B
  760 		JR   PP
  770 P3:	LD   A,3
  780 		LD   DE,&H0C0F
  790 PP:	LD   HL,106
  800 		CALL END2
  810 		LD   E,D
  820 		LD   HL,101
  830 		CALL END2
  840 		LD   HL,98
  850 		LD   E,B
  860 		CALL END2
  870 		RET 

mudaslt
   10 		ORG  &H9145
   11 		LD   A,(&HB00C)		; * Set to RAM RAM RAM RAM
   12 		LD   (&HFFFF),A		; *
   13 		DI			; Disable interruptions
   12 		LD   A,(&HB007)		; *
   14 		LD   B,A		; *
   15 		LD   A,(&HB002)		; *  Check if slot is RAM
   16 		CP   B			; *
   17 		JP   NZ,NORM		; *  and the page is 2
   18 		LD   B,2		; *
   19 		LD   A,(&HB001)		; *  If yes, call routine at C000
   20 		CP   B			; *
   21 		JP   NZ,NORM		; *
   22 		CALL &HC000		; *
   23		EI			; Enable interruptions
   24 		RET 
   30 NORM:	LD   HL,&HB000
   40 		LD   A,(HL)
   50 		JP   ENASS		; Call change subslots routine
   60 INI:	LD   HL,&HB001		; Check current page
   70 		LD   B,(HL)
   80 		LD   D,B
   90 		LD   A,2
  100 		CP   B
  110 		JR   NZ,N1		; If page is NOT 2, then go to N1
  120 D1:	CALL &HC000		; If it is, call the routine at C000 (page 3)
  130 		JR   FIM
  140 N1:	XOR  A			; 
  150 		CP   B			; If page is 0 then
  160 		JR   NZ,N2		; Call routine at page 3
  170 		JR   D1			;
  180 N2:	LD   HL,&HB002
  190 		LD   C,(HL)
  200 		LD   A,3
  210 LI1:	SLA  C
  220 		SLA  C
  230 		SLA  A
  240 		SLA  A
  250 		DJNZ LI1
  260 LF1:	CPL 
  270 		LD   B,A
  280 		IN   A,(&HA8)
  290 		AND  B
  300 		OR   C
  310 		OUT  (&HA8),A		; Make slot active on page 0 or 3
  320 		LD   A,3
  330 		CP   D
  340 		JR   Z,COPY		; If page is 3 then set copy to C000
  350 		JR   FIM		; Else end
  360 COPY:	LD   DE,&HC000
  370 		LD   HL,&H4000
  380 L3:	LD   A,(DE)
  390 		LD   (HL),A
  400 		INC  DE
  410 		INC  HL
  420 		XOR  A
  430 		CP   E
  440 		JR   NZ,L3
  450 		CP   D
  460 		JR   NZ,L3
  470 		LD   HL,&HB000
  480 		LD   A,(HL)
  490 		OUT  (&HA8),A
  500 FIM:	CALL RCRAM
  510 		EI 
  520 		RET 
  530 ENASS:	LD   HL,&HB002		; Change to required subslot
  540 		LD   C,(HL)		; (B002 e B003)
  550 		LD   B,3
  560 ENL1:	SLA  C
  570 		SLA  C
  580 		DJNZ ENL1
  590 		LD   B,&B00111111
  600 		AND  B
  610 		ADD  A,C
  620 		OUT  (&HA8),A		; Make SLxxxxxx
  630 		LD   HL,&HB001
  640 		LD   B,(HL)
  650 		LD   HL,&HB003
  660 		LD   D,(HL)
  670 		XOR  A
  680 		CP   B
  690 		LD   A,3
  700 		JR   Z,ENN1
  710 ENL2:	SLA  D
  720 		SLA  D
  730 		SLA  A
  740 		SLA  A
  750 		DJNZ ENL2
  760 ENN1:	CPL 
  770 		LD   C,A
  780 		LD   HL,&HFFFF
  790 		LD   A,(HL)
  800 		CPL 
  810 		AND  C
  820 		ADD  A,D
  830 		LD   (HL),A
  840 		LD   HL,&HB000
  850 		LD   A,(HL)
  860 		OUT  (&HA8),A
  870 		JP   INI		; Do not use stacks (RET) here 
  890 RETSS:	IN   A,(&HA8)		; Recover slot
  900 		LD   D,A
  910 		LD   HL,&HB002
  920 		LD   C,(HL)
  930 		LD   B,3
  940 REL1:	SLA  C
  950 		SLA  C
  960 		DJNZ REL1
  970 		LD   B,&B00111111
  980 		AND  B
  990 		ADD  A,C
 1000 		OUT  (&HA8),A
 1010 		XOR  A
 1020 		LD   HL,&HFFFF
 1030 		LD   (HL),A
 1040 		LD   A,D
 1050 		OUT  (&HA8),A
 1060 		RET 
 1200 RCRAM:	LD   A,(&HB001)
 1201 		LD   B,1
 1202 		CP   B
 1203 		RET  Z			; If page is 1, back
 1210 		LD   A,(&HB002)
 1215 		LD   B,A
 1220 		LD   A,(&HB007)
 1230 		CP   B			; The current slot is RAM?
 1240 		JP   NZ,RETSS		; If not, got to RETSS
 1280 RCR:	LD   A,(&HB00C)		; If it is, recover RAM subslots
 1370 		LD   (&HFFFF),A
 1380 		RET 

main
   10 		ORG  &H9230
   20 		CALL &H6C		; INITTXT (Screen 0)
   30 		LD   HL,&HFCA9		; *
   40 		LD   A,1		; * Hide cursor 
   50 		LD   (HL),A		; *
   60 		LD   DE,&H8E0C		; % 
   70 		LD   HL,&HC000		; %
   80 		LD   B,&H39		; % Copy "copyslot"
   90 SLFC:	LD   A,(DE)		; % to page 3
  100 		LD   (HL),A		; % 
  110 		INC  DE			; %
  120 		INC  HL			; %
  130 		DJNZ SLFC		; %
  140 		CALL &H9000		; Extract and print the screen
  145		CALL &H8DBD		; Call "salcxt"
  150 		IN   A,(&HA8)		; *
  160 		LD   B,A		; *
  170 		LD   A,&B00110000	; * Get slots configuration
  180 		AND  B			; * and chage the format to
  190 		SRL  A			; * RAM RAM RAM ROM 
  200 		SRL  A			; *  3   2   1   0   
  210 		OR   B			; *
  220 		OUT  (&HA8),A		; *
  230 		LD   HL,&HB000		; % Notify slots configuration 
  240 		LD   (HL),A		; % to B000
  250 		XOR  A			; Clear register A
  260 		LD   B,6		; *
  270 LP1:	INC  HL			; * Clear all variables
  280 		LD   (HL),A		; * from B001 to B006
  290 		DJNZ LP1		; *
  300 		CALL &H9145		; Routine "Muda Slot" (change slot)
  310 TECL:	CALL &H9018		; Routine "Dump de Memoria" (memory dump)
  320 		CALL &H909B		; Routine "Informacoes" (informations)
  330 		CALL &H9F		; CHGET - wait for key pressed
  340 		LD   B,A		; % 
  350 		LD   B,&H1B		; % 
  360 		CP   B			; % 
  370 		JR   Z,ESC		; % 
  380 		LD   B,&H1D		; % 
  390 		CP   B			; % 
  400 		JR   Z,ESQ		; % 
  410 		LD   B,&H1C		; % 
  420 		CP   B			; % 
  430 		JR   Z,DIR		; % 
  440 		LD   B,&H1E		; % 
  450 		CP   B			; % 
  460 		JP   Z,CIMA		; % 
  470 		LD   B,&H1F		; % 
  480 		CP   B			; % 
  490 		JP   Z,BAIXO		; % 
  500 		LD   B,&H53		; % Switch (key)
  510 		CP   B			; % {
  520 		JP   Z,S		; %   case ...
  530 		LD   B,&H73		; % }
  540 		CP   B			; % 
  550 		JP   Z,S		; % 
  560 		LD   B,&H50		; % 
  570 		CP   B			; % 
  580 		JP   Z,P		; % 
  590 		LD   B,&H70		; % 
  600 		CP   B			; % 
  610 		JP   Z,P		; % 
  620 		LD   B,&H55		; % 
  630 		CP   B			; % 
  640 		JP   Z,U		; % 
  650 		LD   B,&H75		; % 
  660 		CP   B			; % 
  670 		JP   Z,U		; % 
  680 		JP   TECL		; % 
  690 ESC:	LD   HL,&HB000		; *
  700 		LD   A,(HL)		; *
  710 		LD   B,A		; *
  720 		LD   A,&B11110000	; * Case Esc:
  730 		AND  B			; * Recover original slots configuration,
  740 		OUT  (&HA8),A		; * clear the screen an exit
  745		CALL ZEROSS		; * 
  750 		XOR  A			; *
  760 		CALL &HC3		; *
  761		CALL &H8D92		; * Recover context (recctx)
  762		XOR  A			; *
  763		LD   (&HFCA9),A		; * Recover system variable
  770 		RET 			; *
  780 ESQ:	LD   HL,&HB006		; % 
  790 		LD   B,(HL)		; % 
  800 		LD   A,&HFB		; % 
  810 		ADD  A,B		; % 
  820 		LD   B,&HFB		; % 
  830 		CP   B			; % 
  840 		JP   Z,TECL		; % 
  850 		JP   C,ESQ1		; % Case Esq: (esquerda = left)
  860 		LD   A,0		; % Go back 5 memory pages
  870 ESQ1:	LD   (HL),A		; % 
  880 		LD   DE,(&HB004)	; % 
  890 		JR   C,ESQ2		; % 
  900 		LD   L,0		; % 
  910 		LD   A,&HF0		; % 
  920 		AND  D			; % 
  930 		LD   H,A		; % 
  940 		JR   ESQ3		; % 
  950 ESQ2:	LD   HL,&HFD80		; % 
  960 		ADD  HL,DE		; % 
  970 ESQ3:	LD   (&HB004),HL	; % 
  980 		CALL &H9018		; % 
  990 		JP   TECL		; % 
 1000 DIR:	LD   HL,&HB006		; * 
 1010 		LD   B,(HL)		; * 
 1020 		LD   A,5		; * 
 1030 		ADD  A,B		; * 
 1040 		LD   B,&H84		; * 
 1050 		CP   B			; * 
 1060 		JP   Z,TECL		; * 
 1070 		LD   B,&H7F		; * 
 1080 		CP   B			; * 
 1090 		JP   C,D1		; * 
 1100 		LD   A,&H7F		; * Case Dir: (direita = right)
 1110 D1:	LD   (HL),A		; * Go foward 5 memory pages
 1120 		LD   DE,(&HB004)	; * 
 1130 		JR   C,D2		; * 
 1140 		LD   L,&H80		; * 
 1150 		LD   A,&HF0		; * 
 1160 		AND  D			; * 
 1170 		LD   D,&HF		; * 
 1180 		ADD  A,D		; * 
 1190 		LD   H,A		; * 
 1200 		JR   D3			; * 
 1210 D2:	LD   HL,&H0280		; * 
 1220 		ADD  HL,DE		; * 
 1230 D3:	LD   (&HB004),HL	; * 
 1240 		CALL &H9018		; * 
 1250 		JP   TECL		; * 
 1260 CIMA:	LD   HL,&HB006		; % 
 1270 		LD   B,(HL)		; % 
 1280 		XOR  A			; % 
 1290 		CP   B			; % 
 1300 		JP   Z,TECL		; % 
 1310 		DEC  B			; % Case Cima: (up)
 1320 		LD   (HL),B		; % Go back 1 page 
 1330 		LD   DE,(&HB004)	; % 
 1340 		LD   HL,&HFF80		; % 
 1350 		ADD  HL,DE		; % 
 1360 		LD   (&HB004),HL	; % 
 1370 		CALL &H9018		; % 
 1380 		JP   TECL		; % 
 1390 BAIXO:	LD   HL,&HB006		; * 
 1400 		LD   B,(HL)		; * 
 1410 		LD   A,&H7F		; * 
 1420 		CP   B			; * 
 1430 		JP   Z,TECL		; * 
 1440 		INC  B			; * Case Baixo: (down)
 1450 		LD   (HL),B		; * Go foward 1 page
 1460 		LD   DE,(&HB004)	; * 
 1470 		LD   HL,&H0080		; * 
 1480 		ADD  HL,DE		; * 
 1490 		LD   (&HB004),HL	; * 
 1500 		CALL &H9018		; * 
 1510 		JP   TECL		; * 
 1520 S:	LD   HL,&HB002		; % 
 1530 		LD   A,(HL)		; % 
 1540 PUS:	INC  A			; %   
 1550 		LD   B,4		; % 
 1560 		CP   B			; % Case S:
 1570 		JR   NZ,S1		; % Go to next slot
 1580 		XOR  A			; % 
 1590 S1:	LD   (HL),A		; % 
 1600 		CALL INISLT		; % 
 1610 		CALL &H9145		; % 
 1620 		JP   TECL		; % 
 1630 U:	LD   HL,&HB003		; * Case U:
 1640 		LD   A,(HL)		; * Go to next subslot
 1650 		JR   PUS		; * 
 1660 P:	LD   HL,&HB001		; % Case P:
 1670 		LD   A,(HL)		; % Go to next page
 1680 		JR   PUS		; % 
 1690 INISLT:	LD   HL,&HB001		; * 
 1700 		LD   B,(HL)		; * 
 1710 		LD   HL,&HB005		; * 
 1720 		XOR  A			; * 
 1730 		CP   B			; * 
 1740 		JR   NZ,INI2		; * 
 1750 		LD   (HL),A		; * 
 1760 		JR   BACK		; * 
 1770 INI2:	LD   A,1		; * 
 1780 		CP   B			; * Routine to perform
 1790 		JR   NZ,INI3		; * some adjustments
 1800 		LD   A,&H40		; * 
 1810 		LD   (HL),A		; * 
 1820 		JR   BACK		; * 
 1830 INI3:	LD   A,2		; * 
 1840 		CP   B			; * 
 1850 		JR   NZ,INI4		; * 
 1860 		LD   A,&H80		; * 
 1870 		LD   (HL),A		; * 
 1880 		JR   BACK		; * 
 1890 INI4:	LD   A,&HC0		; * 
 1900 		LD   (HL),A		; * 
 1910 BACK:	DEC  HL			; * 
 1920 		XOR  A			; * 
 1930 		LD   (HL),A		; * 
 1940 		LD   HL,&HB006		; * 
 1950 		LD   (HL),A		; * 
 1960 		RET 			; *
 1970 ZEROSS:	LD   B,A		; % 
 1980 		LD   C,&B00111111	; % 
 1990 		AND  C			; % 
 2000 		LD   HL,&HFFFF		; % This routine recover
 2010 		DI			; % the initial slots
 2020 		OUT  (&HA8),A		; % configuration
 2030 		XOR  A			; %  
 2040 		LD   (HL),A		; % 
 2050 		LD   A,B		; % 
 2060 		OUT  (&HA8),A		; % 
 2070 		EI
 2080 		RET


Marcelo Silveira
Systems and Computing Engineer
Expert in Image Processing and Artificial Intelligence
© MarMSX 1999-2024