1 ; **************************************************************************** 2 ; line6.s - TRDOS 386 (TRDOS v2.0.3) Test Program - 'sysvideo' pixel w/r tests 3 ; ---------------------------------------------------------------------------- 4 ; 5 ; 12/02/2021 6 ; 7 ; **************************************************************************** 8 ; nasm line6.s -l line6.txt -o LINE6.PRG -Z error.txt 9 ; (modified from 'line5.s', 12/02/2021) 10 11 ; Draw lines by using 'sysvideo' bh=010Eh (Std VGA mode version) 12 13 ; 14/07/2020 14 ; 31/12/2017 15 ; TRDOS 386 (v2.0) system calls 16 _ver equ 0 17 _exit equ 1 18 _fork equ 2 19 _read equ 3 20 _write equ 4 21 _open equ 5 22 _close equ 6 23 _wait equ 7 24 _create equ 8 25 _rename equ 9 26 _delete equ 10 27 _exec equ 11 28 _chdir equ 12 29 _time equ 13 30 _mkdir equ 14 31 _chmod equ 15 32 _rmdir equ 16 33 _break equ 17 34 _drive equ 18 35 _seek equ 19 36 _tell equ 20 37 _memory equ 21 38 _prompt equ 22 39 _path equ 23 40 _env equ 24 41 _stime equ 25 42 _quit equ 26 43 _intr equ 27 44 _dir equ 28 45 _emt equ 29 46 _ldrvt equ 30 47 _video equ 31 48 _audio equ 32 49 _timer equ 33 50 _sleep equ 34 51 _msg equ 35 52 _geterr equ 36 53 _fpstat equ 37 54 _pri equ 38 55 _rele equ 39 56 _fff equ 40 57 _fnf equ 41 58 _alloc equ 42 59 _dalloc equ 43 60 _calbac equ 44 61 _dma equ 45 62 63 %macro sys 1-4 64 ; 29/04/2016 - TRDOS 386 (TRDOS v2.0) 65 ; 03/09/2015 66 ; 13/04/2015 67 ; Retro UNIX 386 v1 system call. 68 %if %0 >= 2 69 mov ebx, %2 70 %if %0 >= 3 71 mov ecx, %3 72 %if %0 = 4 73 mov edx, %4 74 %endif 75 %endif 76 %endif 77 mov eax, %1 78 ;int 30h 79 int 40h ; TRDOS 386 (TRDOS v2.0) 80 %endmacro 81 82 ; Retro UNIX 386 v1 system call format: 83 ; sys systemcall (eax) , , 84 85 [BITS 32] ; We need 32-bit intructions for protected mode 86 87 [ORG 0] 88 89 START_CODE: 90 ; clear bss 91 00000000 BF[D8030000] mov edi, bss_start 92 00000005 B952000000 mov ecx, (bss_end - bss_start)/4 93 ;xor eax, eax 94 0000000A F3AB rep stosd 95 96 ; program message 97 0000000C BE[73020000] mov esi, program_msg 98 00000011 E84F010000 call print_msg 99 100 00000016 30E4 xor ah, ah 101 ;int 16h ; KEYBOARD - READ CHAR FROM BUFFER, WAIT IF EMPTY 102 ; Return: AH = scan code, AL = character 103 00000018 CD32 int 32h ; TRDOS 386 Keyboard interrupt 104 105 ; set VGA mode by using int 31h 106 0000001A 66B81300 mov ax, 13h ; mode 13h ; 107 0000001E CD31 int 31h ; real mode: int 10h 108 00000020 EB0E jmp short set_mode_13h_ok 109 110 terminate: 111 00000022 E8BB010000 call set_text_mode 112 sys _exit 112 <1> 112 <1> 112 <1> 112 <1> 112 <1> %if %0 >= 2 112 <1> mov ebx, %2 112 <1> %if %0 >= 3 112 <1> mov ecx, %3 112 <1> %if %0 = 4 112 <1> mov edx, %4 112 <1> %endif 112 <1> %endif 112 <1> %endif 112 00000027 B801000000 <1> mov eax, %1 112 <1> 112 0000002C CD40 <1> int 40h 113 halt: 114 0000002E EBFE jmp short halt 115 116 set_mode_13h_ok: 117 00000030 B3A2 mov bl, 162 ; color 118 00000032 881D[D8030000] mov [color], bl 119 120 ; Save default values of rectangles 121 00000038 BE[2D030000] mov esi, rectangles 122 0000003D BF[E0030000] mov edi, restorebuff 123 00000042 B928000000 mov ecx, (20*8)/4 124 00000047 F3A5 rep movsd 125 126 next_pos: 127 00000049 E828010000 call drawrect 128 waitforkey: 129 0000004E B401 mov ah, 1 130 00000050 CD32 int 32h 131 00000052 740C jz short getkey 132 00000054 66FF05[DE030000] inc word [counter] 133 0000005B 90 nop 134 0000005C 90 nop 135 0000005D 90 nop 136 0000005E EBEE jmp short waitforkey 137 getkey: 138 00000060 30E4 xor ah, ah 139 00000062 CD32 int 32h 140 141 00000064 663D032E cmp ax, 2E03h 142 00000068 74B8 je short terminate 143 0000006A 3C1B cmp al, 1Bh ; ESC key 144 0000006C 74B4 je short terminate 145 _0: 146 0000006E 3C2B cmp al, '+' 147 00000070 7517 jne short _1 148 149 00000072 FE05[D8030000] inc byte [color] 150 00000078 803D[D8030000]FF cmp byte [color], 255 151 0000007F 76C8 jna short next_pos 152 00000081 FE0D[D8030000] dec byte [color] 153 00000087 EBC5 jmp short waitforkey 154 _1: 155 00000089 3C2D cmp al, '-' 156 0000008B 7510 jne short _2 157 158 0000008D FE0D[D8030000] dec byte [color] 159 00000093 79B4 jns short next_pos 160 00000095 FE05[D8030000] inc byte [color] 161 0000009B EBB1 jmp short waitforkey 162 _2: 163 0000009D 3C20 cmp al, 20h ; space 164 0000009F 7509 jne short _3 165 000000A1 8005[D8030000]08 add byte [color], 8 166 000000A8 EB9F jmp short next_pos 167 _3: 168 000000AA 80FC4B cmp ah, 4Bh 169 000000AD 7509 jne short _4 170 ; left arrow 171 000000AF C605[DC030000]01 mov byte [direction], 1 172 000000B6 EB91 jmp short next_pos 173 _4: 174 000000B8 80FC4D cmp ah, 4Dh 175 000000BB 7509 jne short _5 176 ; right arrow 177 000000BD C605[DC030000]02 mov byte [direction], 2 178 000000C4 EB83 jmp short next_pos 179 _5: 180 000000C6 80FC50 cmp ah, 50h 181 000000C9 750C jne short _6 182 ; down arrow 183 000000CB C605[DC030000]03 mov byte [direction], 3 184 000000D2 E972FFFFFF jmp next_pos 185 _6: 186 000000D7 80FC48 cmp ah, 48h 187 000000DA 750C jne short _7 188 ; up arrow 189 000000DC C605[DC030000]04 mov byte [direction], 4 190 000000E3 E961FFFFFF jmp next_pos 191 _7: 192 000000E8 80FC47 cmp ah, 47h ; Home key 193 000000EB 752E jne short _9 194 _8: 195 000000ED E8DE000000 call beep 196 000000F2 E8C4000000 call clear_vpage 197 000000F7 C605[D1030000]18 mov byte [posdx], 24 198 000000FE C605[D3030000]18 mov byte [posdy], 24 199 00000105 B928000000 mov ecx, (20*8)/4 200 0000010A BE[E0030000] mov esi, restorebuff 201 0000010F BF[2D030000] mov edi, rectangles 202 00000114 F3A5 rep movsd 203 00000116 E92EFFFFFF jmp next_pos 204 _9: 205 0000011B 80FC4F cmp ah, 4Fh ; End key 206 0000011E 7509 jne short _10 207 00000120 C605[D8030000]A2 mov byte [color], 162 208 00000127 EBC4 jmp short _8 209 _10: 210 00000129 663D0D1C cmp ax, 1C0Dh 211 0000012D 7511 jne short _11 212 0000012F E89C000000 call beep 213 00000134 8005[D8030000]04 add byte [color], 4 214 0000013B E909FFFFFF jmp next_pos 215 _11: 216 00000140 80FC49 cmp ah, 49h ; Page UP 217 00000143 750B jne short _12 218 00000145 FE0D[D8030000] dec byte [color] 219 0000014B E9F9FEFFFF jmp next_pos 220 _12: 221 00000150 80FC51 cmp ah, 51h ; Page Down 222 00000153 750B jne short _13 223 00000155 FE05[D8030000] inc byte [color] 224 0000015B E9E9FEFFFF jmp next_pos 225 _13: 226 00000160 E9E9FEFFFF jmp waitforkey 227 228 print_msg: 229 00000165 B40E mov ah, 0Eh 230 00000167 BB07000000 mov ebx, 7 231 ;mov bl, 7 ; char attribute & color 232 p_next_chr: 233 0000016C AC lodsb 234 0000016D 08C0 or al, al 235 0000016F 7404 jz short p_retn ; retn 236 00000171 CD31 int 31h 237 00000173 EBF7 jmp short p_next_chr 238 p_retn: 239 00000175 C3 retn 240 241 drawrect: 242 ; draw rectangles 243 00000176 803D[DC030000]00 cmp byte [direction], 0 244 0000017D 760A jna short dr_x 245 0000017F E837000000 call clear_vpage 246 00000184 E860000000 call change_positions 247 dr_x: 248 00000189 BE[2D030000] mov esi, rectangles ; predefined dimensions 249 0000018E BF[80040000] mov edi, rectbuffer ; final rectangle buffer 250 00000193 B914000000 mov ecx, 20 ; 20 lines, 5 rectangles 251 dr_y: 252 00000198 AD lodsd 253 00000199 AB stosd ; position 254 0000019A AD lodsd ; 255 0000019B AB stosd ; length (and type, h/v) 256 0000019C E2FA loop dr_y 257 dr_z: 258 0000019E BE[80040000] mov esi, rectbuffer 259 ; BL bit 5 = 1 -> write lines via user buffer 260 sys _video, 012Eh, [color], 20 260 <1> 260 <1> 260 <1> 260 <1> 260 <1> %if %0 >= 2 260 000001A3 BB2E010000 <1> mov ebx, %2 260 <1> %if %0 >= 3 260 000001A8 8B0D[D8030000] <1> mov ecx, %3 260 <1> %if %0 = 4 260 000001AE BA14000000 <1> mov edx, %4 260 <1> %endif 260 <1> %endif 260 <1> %endif 260 000001B3 B81F000000 <1> mov eax, %1 260 <1> 260 000001B8 CD40 <1> int 40h 261 000001BA C3 retn 262 263 clear_vpage: 264 000001BB 30C0 xor al, al 265 000001BD 8605[D8030000] xchg al, [color] 266 000001C3 50 push eax 267 000001C4 E8D5FFFFFF call dr_z 268 000001C9 58 pop eax 269 000001CA A2[D8030000] mov [color], al 270 000001CF C3 retn 271 272 beep: 273 ; call beep function (16/64 second, 886Hz) 274 sys _audio, 16, 1331 274 <1> 274 <1> 274 <1> 274 <1> 274 <1> %if %0 >= 2 274 000001D0 BB10000000 <1> mov ebx, %2 274 <1> %if %0 >= 3 274 000001D5 B933050000 <1> mov ecx, %3 274 <1> %if %0 = 4 274 <1> mov edx, %4 274 <1> %endif 274 <1> %endif 274 <1> %endif 274 000001DA B820000000 <1> mov eax, %1 274 <1> 274 000001DF CD40 <1> int 40h 275 000001E1 C3 retn 276 277 set_text_mode: 278 000001E2 30E4 xor ah, ah 279 000001E4 B003 mov al, 3 280 ;int 10h ; al = 03h text mode, int 10 video 281 000001E6 CD31 int 31h ; TRDOS 386 - Video interrupt 282 000001E8 C3 retn 283 284 change_positions: 285 000001E9 B914000000 mov ecx, 20 ; 20 lines, 5 rectangles 286 000001EE 803D[DC030000]02 cmp byte [direction], 2 287 000001F5 7749 ja short chgpos3 ; scroll down/up 288 000001F7 8A25[CD030000] mov ah, [maxdx] 289 000001FD A0[D1030000] mov al, [posdx] 290 00000202 BE[2D030000] mov esi, rectangles ; start address 291 00000207 7422 je short chgpos1 ; slide to right 292 ; slide to left 293 00000209 20C0 and al, al 294 0000020B 7611 jna short chgpos_beep 295 0000020D FEC8 dec al 296 0000020F A2[D1030000] mov [posdx], al 297 ; (horizontal positions) -L- 298 chgpos0: 299 00000214 66FF0E dec word [esi] 300 00000217 83C608 add esi, 8 301 0000021A E2F8 loop chgpos0 302 0000021C EB05 jmp short chgpos_retn 303 chgpos_beep: 304 0000021E E8ADFFFFFF call beep 305 chgpos_retn: 306 00000223 C605[DC030000]00 mov byte [direction], 0 307 0000022A C3 retn 308 chgpos1: 309 0000022B 38E0 cmp al, ah ; right (dx) limit ? 310 0000022D 73EF jnb short chgpos_beep 311 0000022F FEC0 inc al 312 00000231 A2[D1030000] mov [posdx], al 313 ; (horizontal positions) -R- 314 chgpos2: 315 00000236 66FF06 inc word [esi] 316 00000239 83C608 add esi, 8 317 0000023C E2F8 loop chgpos2 318 0000023E EBE3 jmp short chgpos_retn 319 chgpos3: 320 00000240 8A25[CF030000] mov ah, [maxdy] 321 00000246 A0[D3030000] mov al, [posdy] 322 0000024B BE[2F030000] mov esi, rectangles+2 ; start address 323 00000250 803D[DC030000]03 cmp byte [direction], 3 324 00000257 770D ja short chgpos4 ; scroll up 325 ; scroll down 326 00000259 38E0 cmp al, ah ; down (dy) limit ? 327 0000025B 73C1 jnb short chgpos_beep 328 0000025D FEC0 inc al 329 0000025F A2[D3030000] mov [posdy], al 330 ; (vertical positions) -D- 331 00000264 EBD0 jmp short chgpos2 332 chgpos4: 333 ; scroll up 334 00000266 08C0 or al, al 335 00000268 76B4 jna short chgpos_beep 336 0000026A FEC8 dec al 337 0000026C A2[D3030000] mov [posdy], al 338 ; (vertical positions) -U- 339 00000271 EBA1 jmp short chgpos0 340 341 program_msg: 342 00000273 5452444F5320333836- db "TRDOS 386 v2.0.3 - ('sysvideo') Test Program - Draw Lines" 342 0000027C 2076322E302E33202D- 342 00000285 202827737973766964- 342 0000028E 656F27292054657374- 342 00000297 2050726F6772616D20- 342 000002A0 2D2044726177204C69- 342 000002A9 6E6573 343 000002AC 0D0A db 0Dh, 0Ah 344 000002AE 6279204572646F6761- db "by Erdogan Tan - 12/02/2021" 344 000002B7 6E2054616E202D2031- 344 000002C0 322F30322F32303231 345 ;db 0Dh, 0Ah, 0 346 000002C9 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 347 000002CD 507265737320535041- db "Press SPACE or ENTER to change COLOR .." 347 000002D6 4345206F7220454E54- 347 000002DF 455220746F20636861- 347 000002E8 6E676520434F4C4F52- 347 000002F1 202E2E 348 000002F4 0D0A db 0Dh, 0Ah 349 000002F6 507265737320455343- db "Press ESC to exit .." 349 000002FF 20746F206578697420- 349 00000308 2E2E 350 0000030A 0D0A db 0Dh, 0Ah 351 0000030C 0D0A db 0Dh, 0Ah 352 0000030E 507265737320616E79- db "Press any key to continue .." 352 00000317 206B657920746F2063- 352 00000320 6F6E74696E7565202E- 352 00000329 2E 353 nextline: 354 0000032A 0D0A00 db 0Dh, 0Ah, 0 355 356 rectangles: 357 ; rectangle 1 358 0000032D 18001E0012000000 dw 24,30,18,0 359 00000335 29001E0012100000 dw 41,30,4096+18,0 360 0000033D 18002F0012000000 dw 24,47,18,0 361 00000345 18001E0012100000 dw 24,30,4096+18,0 362 ; rectangle 2 363 0000034D 94003C004E000000 dw 148,60,78,0 364 00000355 E1003C003C100000 dw 225,60,4096+60,0 365 0000035D 940077004E000000 dw 148,119,78,0 366 00000365 94003C003C100000 dw 148,60,4096+60,0 367 ; rectangle 3 368 0000036D F40030000C000000 dw 244,48,12,0 369 00000375 FF0030000C100000 dw 255,48,4096+12,0 370 0000037D F4003B000C000000 dw 244,59,12,0 371 00000385 F40030000C100000 dw 244,48,4096+12,0 372 ; rectangle 4 373 0000038D 6C00A80036000000 dw 108,168,54,0 374 00000395 A100A80006100000 dw 161,168,4096+6,0 375 0000039D 6C00AD0036000000 dw 108,173,54,0 376 000003A5 6C00A80006100000 dw 108,168,4096+6,0 377 ; rectangle 5 378 000003AD 0C01A30006000000 dw 268,163,6,0 379 000003B5 1101A3001E100000 dw 273,163,4096+30,0 380 000003BD 0C01C00006000000 dw 268,192,6,0 381 000003C5 0C01A3001E100000 dw 268,163,4096+30,0 382 383 000003CD 3000 maxdx: dw 48 384 000003CF 3000 maxdy: dw 48 385 000003D1 1800 posdx: dw 24 386 000003D3 1800 posdy: dw 24 387 388 bss: 389 390 ABSOLUTE bss 391 392 000003D5 alignb 4 393 394 bss_start: 395 000003D8 color: resd 1 396 000003DC direction: resw 1 397 000003DE counter: resw 1 398 ;posdx: resw 1 399 ;posdy: resw 1 400 401 restorebuff: 402 000003E0 resd 40 403 404 rectbuffer: 405 00000480 resd 40 406 407 bss_end: