--- title: "2068 Code Bytes #3" type: "article" slug: "2068-code-bytes-3" url: "http://localhost/article/2068-code-bytes-3/" markdown_url: "http://localhost/article/2068-code-bytes-3.md" published_at: "2026-03-12T18:29:47+00:00" modified_at: "2026-07-25T23:12:33+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "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…" category: - name: "SMUG Bytes" slug: "smug-bytes" taxonomy: "category" url: "http://localhost/category/periodicals/smug-bytes/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "Machine language programming" slug: "machine-language" taxonomy: "post_tag" url: "http://localhost/tag/machine-language/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Lloyd Dreger" slug: "lloyd-dreger" taxonomy: "indiv" url: "http://localhost/indiv/lloyd-dreger/" publication_r: id: 37935 title: "SMUG Bytes" type: "periodical" url: "http://localhost/periodical/smug-bytes/" authors_r: - name: "Lloyd Dreger" slug: "lloyd-dreger" taxonomy: "indiv" url: "http://localhost/indiv/lloyd-dreger/" volume: "10" issue: "3" issues_articles: - id: 50215 title: "SMUG Bytes v10 n3" type: "issue" url: "http://localhost/issue/smug-bytes-v10-n3/" pages: "3" pubdate: "June 1993" related_articles: - id: 64994 title: "2068 Code Bytes #5" type: "article" url: "http://localhost/article/2068-code-bytes-5/" - id: 64996 title: "2068 Code Bytes #6" type: "article" url: "http://localhost/article/2068-code-bytes-6/" - id: 64998 title: "2068 Code Bytes #7" type: "article" url: "http://localhost/article/2068-code-bytes-7/" - id: 64991 title: "2068 Code Bytes #4" type: "article" url: "http://localhost/article/2068-code-bytes-4/" archive_link: false --- 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 *** #### About this transcription This listing was transcribed from the original scan and checked line by line. The published address column, object-byte column and mnemonics each independently determine the program, so all three were cross-referenced against one another: 65 lines carried both bytes and mnemonics and were fully verified, and a further 66 lines printed without an address column had their object bytes and relative jumps checked. The bytes are authoritative where they disagree with the printed mnemonics. 3 such discrepancies were found: - **64825**, printed as `DEFW 0,0`, should read `DEFW 0` — the next line is at 64827, so this reserves one word, not two; assembling the printed form pushes everything after it four bytes out of place - **64832**, printed as `DEFW 0,0`, should read `DEFW 0` — the next line is at 64834, so this reserves one word, not two - **GUN+68**, printed as `JR Z,EXP`, should read `40,196` — as printed, the displacement targets one byte past EXP, landing inside the LD HL,LIST+11 instruction; 196 targets EXP exactly and reconciles the block 2 symbols and jump targets referenced here are defined outside the published excerpt and could not be verified.