Ireg 1000

The TS1000 owners manual states (p. 123) that upon return from machine code, the I register must have the value 1Eh. However, it can be a lot of fun breaking the rules. The I register points to the upper byte of the character generator table in the ROM. If we change it, the character set changes to a random hash, which can be a useful effect.

This program works by setting a basic variable, IREG, equal to what we want in the I register. RAND USR 16514 will the change the value in the I register. When this register is changed, the screen turns to chaos, which is great for getting peoples attention and simulating explosions.

Only the 1 REM line is necessary for the program to operate, so after you enter and test the program, you may delete all of the other lines. The REM line must contain at least 38 spaces. Use your favorite POKEr program to enter the data. To make this routine relocatable, you would have to change the first instruction (LD HL, 40A3) to point to the name of the variable that you would like to look up the value of(IREG in this case). If you would like to change the name of the variable, then you can change the data at address 40A3 to any variable name that you desire. Just end the name with a + sign.

The Basic program listing has several REM lines containing the source listing of the machine code. It is not necessary to enter these lines into the program.

Enter the data left to right and top to bottom.

DECIMAL POKE TABLE

 33 163  64  34  22  64  14   0
205  28  17  48   2 207   1  35
237  91  28  64 205 246  25 235
 34  28  64 205 205  21 237  71
201  46  55  42  44  21

IREG Basic Listing

   1 REM 5▒RND6-RND: LN 0)K▒INT
▒7 GOSUB ?0RNDLN PLOT ; FOR 60RN
DLN LN + GOSUB ?TAN IREG+
110 REM LD HL,/1000
120 REM LD (H4016),HL
130 REM LD C,0
140 REM CALL H111C
150 REM JR NC,/180
160 REM RST 08
170 REM DATA H01
180 REM INC HL
220 REM LD DE,(H401C)
230 REM CALL H19F6
240 REM EX DE,HL
250 REM LD (H401C),HL
260 REM CALL H15CD
270 REM LD I,A
280 REM RET
1000 REM DATA "IREG+"
2000 REM END
4000 LIST 110
5000 FOR J=0 TO 30 STEP 2
5010 LET IREG=J
5020 RAND USR 16514
5025 NEXT J

IREG Disassembly

4082 21A340     LD HL,40A3
4085 221640 LD (CHADD),HL
4088 0E00 LD C,00
408A CD1C11 CALL 111C
408D 3002 JR NC 4091
408F CF RST 08H
4090 01 ERROR 2
4091 23 INC HL
4092 ED5B1C40 LD DE,(STKND)
4096 CDF619 CALL 19F6
4099 EB EX DE,HL
409A 221C40 LD (STKND),HL
409D CDCD15 CALL 15CD
40A0 ED47 LD I,A
40A2 C9 RET
40A3 2E37 LD L,37
40A5 2A2C15 LD HL,(152C)
40A8 76 HLT
40A9 00 NOP
40AA 6E LD L,(HL)
40AB 0D DEC C
40AC 00 NOP

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.