--- title: "2068 Code Bytes #7" type: "article" slug: "2068-code-bytes-7" url: "http://localhost/article/2068-code-bytes-7/" markdown_url: "http://localhost/article/2068-code-bytes-7.md" published_at: "2026-03-12T18:29:21+00:00" modified_at: "2026-07-25T23:33:36+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "Seventh installment of the Z80 series, presenting the map-cursor and map-editor routine for CONQUEST. Covers PRCURS and PRCUR (cursor initialization and main loop), PIXLOC (screen address from XY coordinates), ATTR (attribute address calculation), PRCHA (print character), INTJOY (joystick-to-cursor translation), TRANS (cursor-to-map coordinate conversion), PUTX (place map element), DOIT (dispatch table using JP(HL)), and four scroll…" 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: "4-7" issues_articles: - id: 50216 title: "SMUG Bytes v10 n4-7" type: "issue" url: "http://localhost/issue/smug-bytes-v10-n4-7/" pages: "7" pubdate: "August - November 1993" related_articles: - id: 64989 title: "2068 Code Bytes #3" type: "article" url: "http://localhost/article/2068-code-bytes-3/" - id: 64991 title: "2068 Code Bytes #4" type: "article" url: "http://localhost/article/2068-code-bytes-4/" - 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/" archive_link: false --- # 2068 Code Bytes #7 Seventh installment of the Z80 series, presenting the map-cursor and map-editor routine for CONQUEST. Covers PRCURS and PRCUR (cursor initialization and main loop), PIXLOC (screen address from XY coordinates), ATTR (attribute address calculation), PRCHA (print character), INTJOY (joystick-to-cursor translation), TRANS (cursor-to-map coordinate conversion), PUTX (place map element), DOIT (dispatch table using JP(HL)), and four scroll routines (SCROLL L/R/U/D). Full assembly listings. *** We continue our discussion of routines from the game Conquest. Up to this point we have discussed in: 1. Game background music 2. Sound effects. 3. General Input routine. 4. General Menu routine. 5. Printing of a double wrapping map. 6. Printing of Graph coordinates. We continue with a map cursor. Whenever one uses a joystick (for that matter a mouse) to direct the movement of various units one needs a cursor to indicate the desired direction. We use a capitol X for the cursor symbol. We need to store the screen coordinates of the cursor in two variables called Curx and Cury. The cursor should not run off the map or be allowed to run over the map coordinates which are down the left side and line 22 acrossed the bottom. Therefore, Curx can be from 1 to 31 (in Basic notation) and Cury from o to 21. The input from this routine not only moves the cursor but also must determine when the joystick button has been pushed as well as interpret all the keyboard commands. Since the keyboard is interpreted differently for the game than in map drawing, 2 different print cursor routines are necessary. The simplest of the two is the one for the map editor which is given below and found in Conquest at 61018. DOEQU 52388not printed as an EQU; taken from the operand at 61314 CURYEQU 52394not printed as an EQU; taken from the operands at 61023 and 61073 CURXEQU 52395not printed as an EQU; taken from the operand at 61020 MAPCOYEQU 52396not printed as an EQU; taken from the operand at 61274 MAPCOXEQU 52397not printed as an EQU; taken from the operand at 61285 6101862,1PRCURSLD A,1INITILIZE CURX AND CURY 6102050,171,204LD (CURX),A 6102350,170,204LD (CURY),A 61026205,63,236CALL PRMAPP 61029237,75,179,204PRCURLD BC,(CURY)THIS IS THE RETURN FOR REPEATS OF THE ROUTINE IN CASE THE INPUT WAS MERELY A MOVE OF THE CURSOR. 61033205,240,238CALL PIXLOCTRANSLATE THE X AND Y INTO THE FIRST PIXEL OF THE SCREEN FILE. 61036235EX DE,HL 6103762,88LD A,”X” 61039205,18,239CALL PRCHAPRINT THE CURSOR 61042205,255,238CALL ATTR 61045126LD A,(HL) 61046230,248AND 248SAVE THE PAPER COLOR 61048198,7ADD A,7MAKE THE INK WHITE. 61050119LD (HL),A 61051205,184,235CALL GETINP(SEE 2068 CODE BYTES #2 FOR THE ROUTINE.) 61054203,119BIT 6,A 6105632,39JR NZ,KEYBOARDA KEY WAS PRESSED. 61058203,127BIT 7,A 6106040,5JR Z,MOVE 61062205,130,239CALL DOIT 6106524,218JR PRCUR 61067229MOVEPUSH HLOLD ATTR ADDR 61068213PUSH DEOLD SCR ADDR 61069197PUSH BCOLD CUR POSN 61070205,48,239CALL INTJOYCHANGE BC TO NEW POSITION OF CURSOR 61073237,67,170,204LD (CURY),BCSAVE NEW COORDINATES OF CURSOR 61077193POP BC 61078205,90,239CALL TRANS 61081205,26,236CALL PMO 61084126LD A,(HL)ERASE OLD CURSOR 61085209POP DEREPRINT OLD POSITION. SEE #5 AND #6 FOR ROUTINE. 61086205,119,237CALL PRUDG 61089126LD A,(HL) 61090205,254,236CALL FINDAT 61093225POP HL 61094119LD (HL),A 6109524,189JR PRCUR 61097254,99KBCP 99“c” 6109932,5JR NZ,KBF 61101205,167,240CALL CENCURIN EDIT MODE, IT CENTERS MAP ON THE CURSOR. IN GAME MODE, ON THE UNIT TO BE MOVED. 6110424,179JR PRCUR 61106254,102KBFCP 102“f” 6110832,5JR NZ,KBGF,G,T AND V ARE THE 4 SCROLLS 61110205,35,238CALL SCROLL 6111324,170JR PRCUR 61115254,103KBGCP 103“g” 6111732,5JR NZ,KBI 61119205,53,238CALL SCROLR 6112224,161JR PRCUR 61124254,105KBICP 105“i” 6112632,5JR NZ,KBM 61128205,244,246CALL IDENTIFY 6113124,152JR PRCUR 61133254,109KBMCP 109“m” 61135200RET ZM AND Q RETURN 61136254,113CP 113“q” 61138200RET Z 61139254,116CP 116“t” 6114132,5JR NZ,KBV 61143205,78,238CALL SCROLU 6114624,137JR PRCUR 61148254,118KBVCP 118“v” 6115032,5JR NZ,KBA 61152205,63,238CALL SCROLD 6115524,128JR PRCUR 61157254,97KBACP 97“a” 61159194,101,238JP PRCURIF MORE KEYS NEED TO BE READ THEY WOULD BE INSERTED HERE. 61162205,120,240CALL WORLD 61165195,101,238JP PRCUR BC = COORDINATES FOR PIXLOC & ATTR 61168120PIXLOCLD A,B 61169230,248AND 248 61171198,64ADD A,64 61173103LD H,A 61174120LD A,B 61175230,7AND 7 6117715RRCA 6117815RRCA 6117915RRCA 61180129ADD A,C 61181111LD L,AHL NOW SCREEN FILE ADDRESS OF BC COORDINATES. 61182201RET 61183120ATTRLD A,B 61184203,47SRA A 61186203,47SRA A 61188203,47SRA A 61190198,88ADD A,88 61192103LD H,A 61193120LD A,B 61194230,7AND 7 6119615RRCA 6119715RRCA 6119815RRCA 61199129ADD A,C 61200111LD L,AHL NOW ATTR ADDR OF BC 61201201RET DE = SCREEN POSN / A = CHARACTER NUMBER 61202197PRACHAPUSH BC 61203229PUSH HL 61204213PUSH DE 6120538,0LD H,0 61207167AND A 6120823RLA 6120923RLA 61210203,20RL H 6121223RLA 61213203,20RL H 61215111LD L,A 61216124LD A,H 61217198,60ADD A,60 61219103LD H,AHL NOW AT PIXELS FOR CHARACTER 612206,8LD B,8 61222126PRCLD A,(HL) 6122318LD (DE),A 6122435INC HL 6122520INC D 6122616,250DJNZ PRC 61228209POP DE 61229225POP HL 61230193POP BC 61231201RET A = REVERSED BITS FROM JOYSTICK BIT 3= R, 2=L, 1=D, 0=U 61232203,71INTJOYBIT 0,A 6123440,1JR Z,IJ1 612365DEC B 61237203,79IJ1BIT 1,A 6123940,1JR Z,IJ2 612414INC B 61242203,87IJ2BIT 2,A 6124440,1JR Z,IJ3 6124613DEC C 61247203,95IJ3BIT 3,A 6124940,1JR Z,IJ4 6125112INC CNOW CHECK BC TO MAKE SURE NOT OFF SCREEN AS DISCUSSED ABOVE 61252120IJ4LD A,B 61253254,255CP 255 6125532,1JR NZ,IJ5 612575INC B 61258254,22IJ5CP 22 6126032,1JR NZ,IJ6 612624DEC B 61263121IJ6LD A,C 61264254,0CP 0 6126632,1JR NZ,IJ7 6126812INC C 61269254,32IJ7CP 32 61271192RET NZ 6127213DEC C 61273201RET BC = CURSOR COORDINATES. THIS ROUTINE CONVERTS THE CURSOR COORDINATES INTO THE MAP COORDINATES DEPENDING UPON WHAT IS BEING SHOWN ON THE SCREEN 6127458,172,204TRANSLD A,(MAPCOY) 61277129ADD A,C 61278254,65CP 65 6128056,2JR C,TR 61282214,64SUB 64 6128479TRLD C,A 6128558,173,204LD A,(MAPCOX) 61288128ADD A,B 61289254,65CP 65 6129156,2JR C,TR1 61293214,64SUB 64 6129571LD B,ABC NOW IN MAPCOORDINATES 61296201RET 61297205,90,239PUTXCALL TRANS 61300205,26,236CALL PMO 6130358,26,236LD A,(DO) 61306205,7,241CALL SETST 61309216RET C 61310119LD (HL),A 61311195,63,236JP PRMAPP THE VARIABLE DO MUST BE SET BEFORE CALLING THIS ROUTINE. 1= PUT SEA, 2= PUT LAND, 3= PUT MOUNTAIN, 4= PUT SHOAL, 5= PUT CITY, 6=BLOTCH SEA, 7= BLOTCH LAND, 8= GROW SEA, 9= GROW LAND 6131458,164,204DOITLD A,(DO) 61317254,0CP 0 61319200RET Z 6132017,158,239LD DE,TABLE 61323254,6CP 6 6132556,9JR C,D1 61327214,5SUB 5 6132938,0LD H,0 61331167AND A 6133223RLA 61333111LD L,A 6133425ADD HL,DE 61335235D1EX DE,HL 6133626LD A,(DE) 61337111LD L,A 6133819INC DE 6133926LD A,(DE) 61340103LD H,A 61341233JP (HL) 61342113,239TABLEDEFW PUTX 61344168,239DEFW BLOTCH 61346168,239DEFW BLOTCH 61348218,240DEFW GROW 61350218,240DEFW GROW *** #### 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: 190 lines carried both bytes and mnemonics and were fully verified. 9 places were found where the printed columns contradict one another. Which column is at fault is noted line by line; where the evidence does not settle it, that is said plainly: - **61029**, printed as `LD BC,(CURY)`, should read `237,75,170,204` — the byte column is at fault: CURY is 52394 where the same variable is written at 61023 and read back at 61073, so the third byte should be 170 rather than 179 - **61039**, printed as `CALL PRCHA` — the bytes reach the right routine; the two columns simply disagree on its name, which is printed PRCHA here and PRACHA at its definition at 61202. Nothing on the page settles which spelling the author intended, and the code is unaffected either way - **61056**, printed as `JR NZ,KEYBOARD`, should read `JR NZ,KB` — the mnemonic column is at fault: the bytes branch to 61097, which the listing labels KB, and no label KEYBOARD appears anywhere in the excerpt - **61159**, printed as `JP PRCUR`, should read `JP NZ,PRCUR` — the mnemonic column is at fault: byte 194 is a conditional JP NZ, and the CP 97 immediately above requires the condition. The unconditional form at 61165 is byte 195 - **61257**, printed as `INC B` — byte 5 is DEC B, but the printed INC B is what the routine needs, since B holds 255 after the cursor is driven above the top row and has to be brought back to 0. Which column is at fault could not be determined; the same two bytes are used correctly at 61236 and 61241, so this is not a systematic swap - **61262**, printed as `DEC B` — the mirror of 61257: byte 4 is INC B where the printed DEC B is what the routine needs to pull the cursor back to row 21. Again the direction could not be determined from the page - **61291**, printed as `JR C,TR1` — the label is missing rather than off-page: the bytes branch to 61295, which is printed here as LD B,A but carries no label. TR1 belongs on that line - **61303**, printed as `LD A,(DO)`, should read `58,164,204` — the byte column is at fault: DO is 52388 where it is read at 61314, while the operand printed here is 60442, which is the operand of the CALL PMO on the line directly above and appears to have been repeated in error - **61325**, printed as `JR C,D1` — the offset is correct and the label is printed one line early: for DO values below 6 the branch has to land on the LD A,(DE) at 61336 so that DE still points at TABLE, which is what selects the first entry. Landing on the EX DE,HL at 61335, where the listing prints D1, would swap TABLE out of DE The following could not be resolved from the available scan and are reproduced as printed: 61095. If you have a cleaner copy of this issue, corrections are welcome. 15 symbols and jump targets referenced here are defined outside the published excerpt and could not be verified.