2068 Code Bytes #3

Authors

Publication

Pub Details

Date

Pages

See all articles from SMUG Bytes v10 n3

Third installment in a series on interrupt-driven Z80 machine language programming for the Timex/Sinclair 2068. Covers a BLINK routine that alternates two User Defined Graphics characters on screen using variables for timing, position, and attributes, followed by three sound-effects routines: a border-toggle BEEP, a gun/bomb effect, and a whistle-and-bang bomb effect. Full machine code listings with addresses and mnemonics are provided throughout.


We continue our discussion of interrupt driven routines with BLINK which alternates two different User Defined Graphic characters to the screen.

We need a few more variables, namely:

  • TIME–to count down the 1/60th of seconds before the next change.
  • WHICH–Character 1 or 2 presently on screen.
  • CHAR1–Which UDG number (from o to 20, not the Basic #).
  • ATTR1–Attribute of ink/paper for characterl.
  • CHAR2–ZND UDG charcter #.
  • ATTR2–2ND attribute.
  • POSY and POSX–BASIC Type AT 0 to 20 and 0 to 31.
  • ATTRA–Address of attribute…

We enter these at the start of the program together with the variables for the music program and put the Blink part in front of the Tune part which we did in our first 2 parts. We again have a new ORG and DISP which will leave our assembled code at 28000.

The interrupt routine continues with the music which we discussed in previous installments. Remember to change your jump address at 65022. You also have to write a routine to enter all the Blink variables.

There are other ways of creating sounds without using the sound generator. One of these is the toggle of the border output–register 294. This is used in Beep. It is such a short routine it fits almost anywhere you want to put it and so is given without addresses.

War games require good shooting and bomb effects. In this routine the whistle and the bang produce a bomb effect. Just doing the bang is a good gun effect by itself.

The game uses a saved variable called EFFECT to toggle on and off the bomb or gun sounds. Again, the routine can go anywhere so we give it without addresses–the XXX being dependent upon where it is assembled.

This completes the sound and interrupt driven programs. Next time we will give you a general menu routine, one that can be used on any size up to a full screen with a cursur that jumps from top to bottom automatically.

ORGEQU 64817
DISPEQU 28714
TVFLAGEQU 23612
6481720TIME1DEFB 20
648181WHICHDEFB 1
648190CHAR1DEFB 0
648200ATTR1DEFB 0
648210CHAR2DEFB 0
648220ATTR2DEFB 0
648230POSYDEFB 0
648240POSXDEFB 0
648250,0ATTRADEFW 0,0
And Previously:
648271SOUNDFDEFB 1
648281TUNEDEFB 1
648290FINEDEFB 0
648300COARSEDEFB 0
648310TIMEDEFB 0
648320,0NEXTDEFW 0,0
We call this address:
64834245BLINKPUSH AF
64835229PUSH HL
64836197PUSH BC
64837213PUSH DE
648388EX AF,AF’
64839217EXX
64840245PUSH AF
64841229PUSH HL
64842197PUSH BC
64843213PUSH DE
WE HAVE SAVED ALL VARIABLES NOW FORCE USE OF TOP SCREEN
6484458,60,92LD A,(TVFLAG)
64847245PUSH AF
64848203,135RES 0,A
6485050,60,92LD (TVFLAG),A
6485333,49,253LD HL,TIME1
6485653DEC (HL)
IF NOT ZERO NOT YET TIME TO CHANGE
6485732,46JR NZ,PLAY
RESET THE BLINK CLOCK
6485954,20LD (HL),20
6486135INC HLTO WHICH
6486262,2LD A,2
64864190CP (HL)
IS WHICH =2ND CHAR?
6486532,3JR NZ,BK1
6486753DEC (HL)SET TO 1
6486824,3JR BK2
6487052BK1INC (HL)SET TO 2
6487135INC HL–CHAR1
6487235INC HL–ATTR1
6487335BK2INC HL–CHAR2/CHAR1
64874126LD A,(HL)
64875254,0CP 0— IF TRUE, BLINK NOT BEING USED
6487740,26JR Z,PLAY
64879229PUSH HL
64880245PUSH AF
USE POSX AND POSY TO DO AN AT
6488162,22LD A,22
64883215RST 16
6488458,56,253LD A,(POSX)
64887215RST 16
6488858,55,253LD A,(POSY)
64891215RST 16
64892241POP AF
64893230,15AND 15
64895198,144ADD A,144
A is now the Basic UDG character #
64897215RST 16
64898225POP HL
6489935INC HL–TO ATTR
64900126LD A,(HL)
6490142,57,253LD HL,(ATTRA)
64904119LD (HL),A
64905241PLAYPOP AF
6490650,60,92LD (TVFLAG),A
243BEEPDI
175XOR A
1,254,0LD BC,254
22,0LD D,0
203,231BOSET 4,A
237,121OUT (C),A
16,254B1DJNZ B1
203,167RES 4,A
237,121OUT (C),A
16,254B2DJNZ B2first byte obscured by scan blob; reconstructed from DJNZ opcode
21DEC D
32,241JR NZ,BO
251EI
201RET
58,0,0GUNLD A,(EFFECT)printed 58,xxx,xxx
254,0CP 0
200RET Z
197PUSH BC
FIRST STOP THE MUSIC
205,53,255CALL 65333(STOP)
[*unreadable*] ONLY THE BOMB
33,110,0EXPLD HL,LIST+11printed [*unreadable*],XXX,XXX — opcode reconstructed as 33
6,8LD B,8
205,91,0EOCALL INOUT2printed 205,XXX,XXX
16,251DJNZ EO
6,120LD B,120
118EX1HALT
16,253DJNZ EX1
6,4LD B,4
205,91,0BWCALL INOUT2printed 205,XXX,XXX
16,251DJNZ BW
DONE, NOW RESTART MUSIC
205,1,255CALL 65281(SETUP)
193POP BC
201RET
58,0,0BOMBLD A,(EFFECT)printed 58,XXX,XXX
254,0CP 0
200RET Z
197PUSH BC
TURN OFF MUSIC
205,53,255CALL 65333(STOP)
62,15LOOPLD A,15
33,99,0LD HL,LISTprinted 33,XXX,XXX
6,2LD B,2
205,82,0BXCALL INOUT1printed 205,XXX,XXX
16,251DJNZ BX
245PUSH AF
126LD A,(HL)
35INC HL
211,245OUT (245),A
241POP AF
60INC A
254,141CP 141
IF DONE JUMP TO GUN
40,197JR Z,EXP
245PUSH AF
211,246OUT (246),A
6,4LD B,4
205,91,0B4CALL INOUT2printed 205,XXX,XXX
241POP AF
118HALT
24,221JR LOOP
245INOUT1PUSH AF
126LD A,(HL)
35INC HL
211,245OUT (245),A
241POP AF
211,246XOUT (246),A
201RET
126INOUT2LD A,(HL)
35INC HL
211,245OUT (245),A
126LD A,(HL)
35INC HL
24,245JR X
0,4,2,7,56,8,15,9,15LISTDEFB 0,4,2,7,56,8,15,9,15
10,15,0,1,6,6,7,7,8,16,9DEFB 10,15,0,1,6,6,7,7,8,16,9
16,10,16,12,56,13,8,9,0DEFB 16,10,16,12,56,13,8,9,0
10,0,12,0,13,0DEFB 10,0,12,0,13,0

Image Gallery

Source Code

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

Scroll to Top