|
| 1 | +#DoubleSizePrint.bas |
| 2 | + |
| 3 | +This routine will print out Strings at double size. It will stop if it reaches the end of the screen, however |
| 4 | +- so you have to deal with new rows on your own! (143 bytes long for main routine) |
| 5 | + |
| 6 | +The core subroutine is capable of printing one character on screen at specified location, in double size. |
| 7 | +Of course, this is the basis for the second subroutine, that takes a string and prints it all. |
| 8 | + |
| 9 | +Both routines are capable of printing from the User Definable Graphics locations. |
| 10 | + |
| 11 | +Usage: |
| 12 | + |
| 13 | +``` |
| 14 | +REM Requires ascii code of character to print. |
| 15 | +doubleSizePrintChar(y, x, code("a")) |
| 16 | +``` |
| 17 | +``` |
| 18 | +REM This version calls the first one, and will print a whole string. |
| 19 | +doubleSizePrint(y, x, thingToPrint$) |
| 20 | +``` |
| 21 | + |
| 22 | +Code: |
| 23 | + |
| 24 | +``` |
| 25 | +SUB doubleSizePrintChar(y as uByte, x as uByte, thingToPrint as uByte) |
| 26 | +' Prints a single character double sized. |
| 27 | +' Takes X and Y values as character positions, like print. |
| 28 | +' takes an ascii code value for a character. |
| 29 | +' By Britlion, 2012. |
| 30 | +
|
| 31 | +ASM |
| 32 | +LD A,(IX+5) ;' Y value |
| 33 | +CP 22 |
| 34 | +JP NC, doubleSizePrintCharEnd |
| 35 | +
|
| 36 | +;' A=y value |
| 37 | +LD E,A |
| 38 | +AND 24 ; calculate |
| 39 | +OR 64 ; screen |
| 40 | +LD H,A ; address |
| 41 | +LD A,E ; for |
| 42 | +AND 7 ; row |
| 43 | +OR a ; Y |
| 44 | +RRA |
| 45 | +RRA |
| 46 | +RRA |
| 47 | +RRA |
| 48 | +LD E,A |
| 49 | +
|
| 50 | +LD A,(IX+7) ;' X Value |
| 51 | +CP 30 |
| 52 | +JP NC, doubleSizePrintCharEnd |
| 53 | +
|
| 54 | +ADD A,E ;' correct address for column value. (add it in) |
| 55 | +LD L,A |
| 56 | +EX DE,HL ;' Save it in DE |
| 57 | +
|
| 58 | +LD A,(IX+9) ;'Character |
| 59 | +
|
| 60 | +CP 164 ;' > UDG "U" ? |
| 61 | +JP NC, doubleSizePrintCharEnd |
| 62 | +
|
| 63 | +CP 32 ;' < space+1? |
| 64 | +JP C, doubleSizePrintCharEnd |
| 65 | +
|
| 66 | +CP 144 ;' >144? |
| 67 | +JP NC, doubleSizePrintCharUDGAddress |
| 68 | +
|
| 69 | +LD L,A |
| 70 | +LD H,0 |
| 71 | +
|
| 72 | +ADD HL,HL |
| 73 | +ADD HL,HL |
| 74 | +ADD HL,HL ;' multiply by 8. |
| 75 | +LD BC,(23606) ;' Chars |
| 76 | +ADD HL,BC ;' Hl -> Character data. |
| 77 | +EX DE,HL ;' DE -> character data, HL-> screen address. |
| 78 | +JP doubleSizePrintCharRotateLoopCharStart |
| 79 | +
|
| 80 | +doubleSizePrintCharUDGAddress: |
| 81 | +LD HL,(23675) ;'UDG address |
| 82 | +SUB 144 |
| 83 | +ADD A,A ;multiply by 8. |
| 84 | +ADD A,A |
| 85 | +ADD A,A |
| 86 | +ADD A,L |
| 87 | +LD L,A |
| 88 | +
|
| 89 | +JR NC, doubleSizePrintCharUDGAddressNoCarry |
| 90 | +INC H |
| 91 | +doubleSizePrintCharUDGAddressNoCarry: |
| 92 | +
|
| 93 | +;' At this point HL -> Character data in UDG block. |
| 94 | +EX DE,HL ;' DE -> character data, HL-> screen address. |
| 95 | +
|
| 96 | +doubleSizePrintCharRotateLoopCharStart: |
| 97 | +LD C,2 ;' 2 character rows. |
| 98 | +doubleSizePrintCharRotateLoopCharRowLoopOuter: |
| 99 | +LD b,4 ;' 4 source bytes to count through per character row. |
| 100 | +doubleSizePrintCharRotateLoopCharRowLoopInner: |
| 101 | + PUSH BC |
| 102 | +
|
| 103 | + LD A,(DE) ;' Grab a bitmap. |
| 104 | + PUSH DE |
| 105 | +
|
| 106 | + LD B,4 |
| 107 | + LD C,A ; Copy byte so we can put two into the big version. |
| 108 | + doubleSizePrintCharRotateLoop1: |
| 109 | + RRA ; one bit into carry |
| 110 | + RR E ; one bit into result |
| 111 | + RR C ; same bit into carry again |
| 112 | + RR E ; duplicated bit into result |
| 113 | + DJNZ doubleSizePrintCharRotateLoop1 |
| 114 | +
|
| 115 | + LD B,4 |
| 116 | + doubleSizePrintCharRotateLoop2: |
| 117 | + RRA |
| 118 | + RR D ; Other register for other half of big 16 bit line. |
| 119 | + RR C |
| 120 | + RR D |
| 121 | + DJNZ doubleSizePrintCharRotateLoop2 |
| 122 | +
|
| 123 | + LD (HL),D ;' Output first byte |
| 124 | + INC HL ;' Move right |
| 125 | + LD (HL),E ;' Second half. |
| 126 | + DEC HL ;' Move left |
| 127 | + INC H ;' Move down |
| 128 | + LD (HL),D ;' Output second row (copy of first), first byte. |
| 129 | + INC HL ;' Move right |
| 130 | + LD (HL),E ; Output second row, second byte |
| 131 | + DEC HL ; Move left |
| 132 | + INC H ; Move down. |
| 133 | + POP DE |
| 134 | + INC DE |
| 135 | + POP BC |
| 136 | +
|
| 137 | +DJNZ doubleSizePrintCharRotateLoopCharRowLoopInner |
| 138 | +; CALL __DECY+2 ;'Jump into the DRAW next_line_down routine, at a convenient point (accounting for the INC H above) |
| 139 | +; Can't seem to call to this at the moment! Here in longhand form: |
| 140 | +
|
| 141 | +ld a, h |
| 142 | +and 7 |
| 143 | +jr nz, doubleSizePrintCharRotateNextCharRow |
| 144 | +ld a, l |
| 145 | +add a, 32 |
| 146 | +ld l, a |
| 147 | +jr c, doubleSizePrintCharRotateNextCharRow |
| 148 | +ld a, h |
| 149 | +sub 8 |
| 150 | +ld h, a |
| 151 | +
|
| 152 | +doubleSizePrintCharRotateNextCharRow: |
| 153 | +
|
| 154 | +DEC C |
| 155 | +JR NZ, doubleSizePrintCharRotateLoopCharRowLoopOuter |
| 156 | +
|
| 157 | +doubleSizePrintCharEnd: |
| 158 | +END ASM |
| 159 | +END SUB |
| 160 | +``` |
| 161 | +``` |
| 162 | +SUB doubleSizePrint(y as uByte, x as uByte, thingToPrint$ as String) |
| 163 | +'Uses doubleSizePrintChar subroutine to print a string. |
| 164 | +'By Britlion, 2012 |
| 165 | +
|
| 166 | + DIM n as uByte |
| 167 | + for n=0 to LEN thingToPrint - 1 |
| 168 | + doubleSizePrintChar(y,x,CODE thingToPrint$(n) ) |
| 169 | + x=x+2 |
| 170 | + next n |
| 171 | +
|
| 172 | +END SUB |
| 173 | +``` |
| 174 | + |
| 175 | +Example: |
| 176 | + |
| 177 | +``` |
| 178 | +cls |
| 179 | +doubleSizePrintChar(0,0,145) |
| 180 | +doubleSizePrint(10,0,"Hello World") |
| 181 | +``` |
0 commit comments