--- title: "2068 Code Bytes #6" type: "article" slug: "2068-code-bytes-6" url: "http://localhost/article/2068-code-bytes-6/" markdown_url: "http://localhost/article/2068-code-bytes-6.md" published_at: "2026-03-12T18:33:10+00:00" modified_at: "2026-07-25T23:34:03+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "Sixth installment of the Z80 series, providing corrections to the issue #5 map routine plus the FINDAT color-attribute routine that assigns display colors to map units and cities for three players, a PAPER routine for background attribute setting, and the PRUDG UDG printer used throughout the CONQUEST map display system. Full assembly listings with addresses…" 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: "5" 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: 64998 title: "2068 Code Bytes #7" type: "article" url: "http://localhost/article/2068-code-bytes-7/" archive_link: false --- # 2068 Code Bytes #6 Sixth installment of the Z80 series, providing corrections to the issue #5 map routine plus the FINDAT color-attribute routine that assigns display colors to map units and cities for three players, a PAPER routine for background attribute setting, and the PRUDG UDG printer used throughout the CONQUEST map display system. Full assembly listings with addresses and mnemonics. *** Correction: In Last month’s routine (issue #5) kindly insert the following 3 bytes of code after address 60457 shoving everything else down 3 bytes: ``` 60548 33 RLA 60459 203,30 RL H ``` The entry address FOR THE PRINT MAP routine than becomes 60479. We now finish our routine to print a wrapping world map to the screen There also were 2 address counting errors as well. This finishes the print a double wrapping map routine. Of course you may want different graphics so may have to write your own attribute routine. You can also have more than 21 UDGs with this routine and can put the pixels anywhere you like merely by changing the address at 60793. In fact we will be doing just that when we print the coordinates for the map with the following routine. By making the coordinates a separate routine, we can choose to print them or not. In the editor, where we need human help (or chew up a lot more space with code) we don’t want the viewer to know where on the map we are. Whereas, in the game coordinates are a definite help. But we don’t want to take too much screen. So we decide to have both numbers of the coordinates take but one character space. Each number is only 3 pixels wide. Using only even numbers makes them easier to read and requires only half as many. As it is, each of 32 coordinate characters is going to require 8 bytes. They will go down the left side and across line 21 (Basic designations). Our map is now complete with coordinates. How about being able to scroll the map in any direction one character at a time? We still have to add a cursor which shouldn’t go off screen or across the coordinates which will be the topic of the next issue. 6045823RLA 60459203,20RL H 60726230,192P1AND 192WE ONLY HAVE UNITS LEFT SO WE CAN WORK WITH ONLY THE TOP TO OWER BITS. 60728254,64CP 64 6073032,6JR NZ,P2 60732205,82,237CALL PAPER 60735198,6ADD A,6ADD Y INK 60737201RET 60738254,128P2CP 128 6074032,6JR NZ,P3 60742205,82,237CALL PAPER 60745198,2ADD A,2ADD R INK 60747201RET 60748205,62,237P3CALL PAPER 60751198,7ADD A,7 60753201RET 60754213PAPERPUSH DE 60755229PUSH HL 6075658,51,123LD A,(PLAYER) 60759167AND A 6076023RLA 6076123RLA 6076223RLA 6076323RLA 6076487LD D,A 6076530,0LD E,0 60767237,87SBC HL,DE 60769126LD A,(HL) 60770254,1CP 1SEA? 6077232,4JR NZ,PA2 6077462,8LD A,8 6077624,10JR PAOUT 60778254,4CP 4MT? 6078048,4JR NC,PA3 6078262,32LD A,32P=G 6078424,2JR PAOUT 6078662,40PA3LD A,40P=AQ 60788225PAOUTPOP HL 60789209POP DE 60790201RET 60791197PRUDGPUSH BC 60792229PUSH HL 6079333,88,255LD HL,65368 60796230,15AND 15 6079823RLA 6079923RLA 6080023RLA 60801133ADD A,L 60802111LD L,A 608036,8LD B,8 60805126UDGLD A,(HL) 6080618LD (DE),A 6080735INC HL 6080820INC D 6080916,250DJNZ UDG 60811225POP HL 60812193POP BC 60813201RET 6081458,173,204PRCOORLD A,(MAPCOX)THE STORAGE PLACE FOR THE UPPER LEFT COORDINATE OF THE SCREEN 6081717,0,64LD DE,16384(0,0 OF THE SCREEN) 6082033,62,208LD HL,COORDWHERE 00 FIRST PIXEL IS STORED 608236,12LD B,12 60825167AND A 6082631RRADIVIDE COORDINATES BY 2 6082748,16JR NC,EVEN 6082960INC ASET A TO NEXT HIGHER NUMBER 60830245AGAINPUSH AF 60831175XOR A 60832205,0,238CALL PRCOPRINT A BLANK 60835123LD A,EADJST DE TO NEXT PRINT POSITION 60836198,32LD A,32 6083895LD A,E 60839254,0CP 0 60841204,251,237CALL Z,SEAM 60844241POP AF 60845205,0,238EVENCALL PRCO 6084860INC A 60849254,33CP 33AT END OF COOR? 6085132,2JR NZ,NOTEND 6085362,1LD A,1RESET TO FIRST 60855245NOTENDPUSH AF 60856123AND A,E 60857198,32ADD A,32 6085995LD E,A 60860254,0CP 0 60862204,231,237CALL Z,SEAM 60865241POP AF 6086616,218DJNZ AGAINNOW DO ACROSS THE BOTTOM 6086817,192,80LD DE,20672 6087158,192,204LD A,(MAPCOY)GET THE Y COORDINATE 608746,16LD B,16 60876167AND A 6087731RRAAGAIN, DIVIDE BY 2 6087848,8JR NC,EVEN1 6088060INC A 60881245AGAPUSH AF 60882175XOR APRINT A BLANK 60883205,0,248CALL PRCO 6088619INC DEADJUST DE TO NEXT PRINT POSITION 60887241POP AF 60888205,0,238EVEN1CALL PRCO 6089119INC DE 6089260INC A 60893254,33CP 33TIME TO WRAP? 6089532,2JR NZ,NOTE 6089762,1LD A,1 6089916,236NOTEDJNZ AGANOW DO ATTRIBUTES BK INK ON W PAPER 6090133,0,88LD HL,ATTRO 6090462,56LD A,56 609066,22LD B,22 6090817,32,0LD DE,32 60911110PC4LD (HL),A 60912167AND A 6091325ADD HL,DE 6091416,251DJNZ PC4 609166,32LD B,32 60918119PC5LD (HL),A 6091935INC HL 6092016,252DJNZ PC5 60922201RET 60923122SEAMLD A,D 60924198,8ADD A,8 6092687LD D,A 60927201RET 60928229PRCOPUSH HL 60929245PUSH AF 60930197PUSH BC 60931213PUSH DE 60932254,32CP 32 6093440,24JR Z,ADH 60936167AND A 6093723RRA 6093823RRA 6093923RRA 6094022,0LD D,0 6094295LD E,A 60943167AND A 6094425ADD HL,DE 60945209POP DE 60946213PUSH DE 609476,8X1LD B,8 60949126PRCO1LD A,(HL) 6095035INC HL 6095120INC D 6095216,250DJNZ PRCO1 60954209POP DE 60955193POP BC 60956241POP AF 60957225POP HL 60958201RET 6095936ADHINC H 6096024,240JR X1 *** #### 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: 152 lines carried both bytes and mnemonics and were fully verified. The bytes are authoritative where they disagree with the printed mnemonics. 9 such discrepancies were found: - **60836**, printed as `LD A,32`, should read `ADD A,32` — byte 198 is ADD A,n; the same instruction is set correctly at 60857 - **60838**, printed as `LD A,E`, should read `LD E,A` — byte 95 is LD E,A; the same instruction is set correctly at 60859 - **60856**, printed as `AND A,E`, should read `LD A,E` — AND A,E is not a Z80 instruction; byte 123 is LD A,E, as set correctly at 60835 - **60934**, printed as `JR Z,ADH` — the offset is correct; the label is one byte low. ADH sits at 60960 once the instruction dropped at 60950 is restored – see 60952 - **60937**, printed as `RRA`, should read `RLA` — byte 23 is RLA, and the routine needs A multiplied by 8 to index the eight-byte coordinate characters; where RRA is genuinely meant, at 60826 and 60877, the byte is 31 - **60938**, printed as `RRA`, should read `RLA` — as 60937 - **60939**, printed as `RRA`, should read `RLA` — as 60937 - **60952**, printed as `DJNZ PRCO1` — the PRCO1 loop is missing LD (DE),A (byte 18) at 60950, which the published listing dropped and then renumbered around; the loop otherwise mirrors PRUDG at 60805. Restoring that byte and shifting 60951 to 60961 up by one resolves this jump and those at 60934 and 60960, and introduces no further disagreement. The printed offset 250 already assumes the six-byte loop - **60960**, printed as `JR X1` — same cause as 60952. X1 is correct at 60947, but this JR itself belongs at 60961 Typesetting artefacts at 60765, 60839, 60860, 60940 (the letter O set for the digit 0) have been silently corrected; the object bytes were never in doubt. The following could not be resolved from the available scan and are reproduced as printed: 60748, 60767, 60862, 60883, 60911. If you have a cleaner copy of this issue, corrections are welcome. 6 symbols and jump targets referenced here are defined outside the published excerpt and could not be verified.