1 ; **************************************************************************** 2 ; circle15.s - TRDOS 386 (TRDOS v2.0.3) Test Program - 'sysvideo' pixel tests 3 ; ---------------------------------------------------------------------------- 4 ; 5 ; 18/02/2021 6 ; 7 ; **************************************************************************** 8 ; nasm circle15.s -l circle15.txt -o CIRCLE15.PRG -Z error.txt 9 ; (modified from 'circle14.s', 18/02/2021) 10 11 ; Draw circle by using 'sysvideo' bx=0305h 12 ; and show diameter and origin by using bx=010Fh 13 14 ; 14/07/2020 15 ; 31/12/2017 16 ; TRDOS 386 (v2.0) system calls 17 _ver equ 0 18 _exit equ 1 19 _fork equ 2 20 _read equ 3 21 _write equ 4 22 _open equ 5 23 _close equ 6 24 _wait equ 7 25 _create equ 8 26 _rename equ 9 27 _delete equ 10 28 _exec equ 11 29 _chdir equ 12 30 _time equ 13 31 _mkdir equ 14 32 _chmod equ 15 33 _rmdir equ 16 34 _break equ 17 35 _drive equ 18 36 _seek equ 19 37 _tell equ 20 38 _memory equ 21 39 _prompt equ 22 40 _path equ 23 41 _env equ 24 42 _stime equ 25 43 _quit equ 26 44 _intr equ 27 45 _dir equ 28 46 _emt equ 29 47 _ldrvt equ 30 48 _video equ 31 49 _audio equ 32 50 _timer equ 33 51 _sleep equ 34 52 _msg equ 35 53 _geterr equ 36 54 _fpstat equ 37 55 _pri equ 38 56 _rele equ 39 57 _fff equ 40 58 _fnf equ 41 59 _alloc equ 42 60 _dalloc equ 43 61 _calbac equ 44 62 _dma equ 45 63 64 %macro sys 1-4 65 ; 29/04/2016 - TRDOS 386 (TRDOS v2.0) 66 ; 03/09/2015 67 ; 13/04/2015 68 ; Retro UNIX 386 v1 system call. 69 %if %0 >= 2 70 mov ebx, %2 71 %if %0 >= 3 72 mov ecx, %3 73 %if %0 = 4 74 mov edx, %4 75 %endif 76 %endif 77 %endif 78 mov eax, %1 79 ;int 30h 80 int 40h ; TRDOS 386 (TRDOS v2.0) 81 %endmacro 82 83 ; Retro UNIX 386 v1 system call format: 84 ; sys systemcall (eax) , , 85 86 [BITS 32] ; We need 32-bit intructions for protected mode 87 88 [ORG 0] 89 90 START_CODE: 91 ; clear bss 92 00000000 BF[D8070000] mov edi, bss_start 93 00000005 B90C050100 mov ecx, (bss_end - bss_start)/4 94 ;xor eax, eax 95 0000000A F3AB rep stosd 96 97 ; program message 98 0000000C BE[8C060000] mov esi, program_msg 99 00000011 E838020000 call print_msg 100 101 00000016 30E4 xor ah, ah 102 ;int 16h ; KEYBOARD - READ CHAR FROM BUFFER, WAIT IF EMPTY 103 ; Return: AH = scan code, AL = character 104 00000018 CD32 int 32h ; TRDOS 386 Keyboard interrupt 105 106 ; Read (copy) 8x8 system fonts 107 0000001A BE[D8870000] mov esi, fontbuff1 108 sys _video, 0C02h, 256, 0 108 <1> 108 <1> 108 <1> 108 <1> 108 <1> %if %0 >= 2 108 0000001F BB020C0000 <1> mov ebx, %2 108 <1> %if %0 >= 3 108 00000024 B900010000 <1> mov ecx, %3 108 <1> %if %0 = 4 108 00000029 BA00000000 <1> mov edx, %4 108 <1> %endif 108 <1> %endif 108 <1> %endif 108 0000002E B81F000000 <1> mov eax, %1 108 <1> 108 00000033 CD40 <1> int 40h 109 110 ; convert 8x8 fonts to 32x32 fonts 111 ; by scaling each font 112 ;mov esi, fontbuff1 113 00000035 BF[D8070000] mov edi, fontbuff2 114 ;mov cx, 256 115 fontconvert: 116 0000003A 51 push ecx 117 0000003B B108 mov cl, 8 118 fntcnv0: 119 0000003D B608 mov dh, 8 120 0000003F 8A16 mov dl, [esi] 121 00000041 46 inc esi 122 fntcnv1: 123 00000042 C1E004 shl eax, 4 124 00000045 D0E2 shl dl, 1 125 00000047 7302 jnc short fntcnv2 126 00000049 0C0F or al, 0Fh 127 fntcnv2: 128 0000004B FECE dec dh 129 0000004D 75F3 jnz short fntcnv1 130 0000004F AB stosd 131 00000050 AB stosd 132 00000051 AB stosd 133 00000052 AB stosd 134 00000053 FEC9 dec cl 135 00000055 75E6 jnz short fntcnv0 136 00000057 59 pop ecx 137 00000058 E2E0 loop fontconvert 138 139 ;mov ax, 4F02h ; vbe function 02h, set video mode 140 ;;int 10h ; bios video interrupt 141 ;mov bx, 4105h ; vbe mode 105h with LFB 142 ;int 31h ; TRDOS 386 - Video interrupt 143 ;cmp ax, 004Fh 144 ;jne short terminate 145 146 ; edx = 0 (do not return LFB Info) 147 148 ; Set Video Mode to 105h ; 1024x768, 256 colors 149 sys _video, 08FFh, 105h 149 <1> 149 <1> 149 <1> 149 <1> 149 <1> %if %0 >= 2 149 0000005A BBFF080000 <1> mov ebx, %2 149 <1> %if %0 >= 3 149 0000005F B905010000 <1> mov ecx, %3 149 <1> %if %0 = 4 149 <1> mov edx, %4 149 <1> %endif 149 <1> %endif 149 <1> %endif 149 00000064 B81F000000 <1> mov eax, %1 149 <1> 149 00000069 CD40 <1> int 40h 150 0000006B 09C0 or eax, eax 151 ;jz short terminate 152 ;mov [LFB_ADDR], edx ; pointer to LFB info table/structure 153 0000006D 7454 jz short terminate 154 155 set_vesa_mode_105h_ok: 156 ; Set squares of numbers from 0 to 255 157 0000006F BF[D88F0000] mov edi, _squares 158 00000074 B9FF000000 mov ecx, 255 159 00000079 BB01000000 mov ebx, 1 160 _ss_x: 161 0000007E 89D8 mov eax, ebx 162 00000080 F7E3 mul ebx 163 00000082 AB stosd 164 00000083 43 inc ebx 165 00000084 E2F8 loop _ss_x 166 167 00000086 C605[E6930000]8C mov byte [tcolor], 140 168 169 ;mov byte [prevd], 510 170 ;mov byte [prevx], 1024/2 171 ;mov byte [prevy], 768/2 172 173 ;mov esi, circle_parameters 174 ;call print_msg 175 reset_color: 176 0000008D C605[F0930000]8E mov byte [color], 142 ; initial color 177 reset_diameter: 178 ;mov eax, 240 179 00000094 B8FF000000 mov eax, 255 ; initial radius 180 newdiameter: 181 ; Set radius to 255 182 ;mov dword [radius], 255 183 ;mov dword [_r2], 65025 184 00000099 A3[E8930000] mov [radius], eax 185 0000009E 89C3 mov ebx, eax 186 000000A0 F7E3 mul ebx 187 000000A2 A3[EC930000] mov [_r2], eax ; square of circle radius 188 ; x2+y2 = r2 189 ; Set Y values for X values from 1 to Radius - 1 190 000000A7 BF[04940000] mov edi, _fx 191 _yy_x: 192 000000AC 4B dec ebx 193 000000AD 7422 jz short center 194 000000AF 89D8 mov eax, ebx 195 000000B1 F7E0 mul eax 196 ; eax = square of ebx 197 000000B3 8B15[EC930000] mov edx, [_r2] 198 000000B9 29C2 sub edx, eax 199 000000BB E8F2030000 call get_squareroot 200 000000C0 AB stosd 201 000000C1 EBE9 jmp short _yy_x 202 203 ; *** 204 205 terminate: 206 000000C3 E804040000 call set_text_mode 207 sys _exit 207 <1> 207 <1> 207 <1> 207 <1> 207 <1> %if %0 >= 2 207 <1> mov ebx, %2 207 <1> %if %0 >= 3 207 <1> mov ecx, %3 207 <1> %if %0 = 4 207 <1> mov edx, %4 207 <1> %endif 207 <1> %endif 207 <1> %endif 207 000000C8 B801000000 <1> mov eax, %1 207 <1> 207 000000CD CD40 <1> int 40h 208 halt: 209 000000CF EBFE jmp short halt 210 211 ; *** 212 213 ; move circle to center of screen 214 center: 215 000000D1 E825030000 call movecenter 216 _0: 217 000000D6 E884010000 call drawcircle 218 waitforkey: 219 000000DB B401 mov ah, 1 220 000000DD CD32 int 32h 221 000000DF 740B jz short getkey 222 000000E1 FE05[E4930000] inc byte [counter] 223 000000E7 90 nop 224 000000E8 90 nop 225 000000E9 90 nop 226 000000EA EBEF jmp short waitforkey 227 getkey: 228 000000EC 30E4 xor ah, ah 229 000000EE CD32 int 32h 230 231 000000F0 663D032E cmp ax, 2E03h 232 000000F4 74CD je short terminate 233 000000F6 3C1B cmp al, 1Bh ; ESC key 234 000000F8 74C9 je short terminate 235 236 000000FA 3C2B cmp al, '+' 237 000000FC 7513 jne short _1 238 239 000000FE A1[E8930000] mov eax, [radius] 240 241 00000103 663DFF00 cmp ax, 255 242 00000107 7351 jnb short _3_ ; beep 243 244 ; delete circle by drawing black circle 245 ; with same diameter and at same coordinate 246 00000109 E87C030000 call black_circle 247 ; increase radius of the circle 248 0000010E 40 inc eax 249 ;mov [radius], eax 250 0000010F EB88 jmp newdiameter ; draw with new diameter 251 _1: 252 00000111 3C2D cmp al, '-' 253 00000113 7516 jne short _2 254 255 00000115 A1[E8930000] mov eax, [radius] 256 257 0000011A 6683F801 cmp ax, 1 258 0000011E 763A jna short _3_ ; beep 259 260 ; delete circle by drawing black circle 261 ; with same diameter and at same coordinate 262 00000120 E865030000 call black_circle 263 ; decrease radius of the circle 264 00000125 48 dec eax 265 ;mov [radius], eax 266 00000126 E96EFFFFFF jmp newdiameter ; draw with new diameter 267 _2: 268 0000012B 3C20 cmp al, 20h ; space 269 0000012D 7509 jne short _3 270 0000012F 8005[F0930000]08 add byte [color], 8 271 00000136 EB9E jmp short _0 272 _3: 273 00000138 80FC4B cmp ah, 4Bh 274 0000013B 7527 jne short _4 275 ; left arrow 276 0000013D A1[E8930000] mov eax, [radius] 277 00000142 3B05[F4930000] cmp eax, [_x0] 278 00000148 7310 jnb short _3_ 279 0000014A E83B030000 call black_circle ; clear current position 280 0000014F FF0D[F4930000] dec dword [_x0] 281 00000155 E97CFFFFFF jmp _0 ; draw 282 _3_: 283 0000015A E841030000 call beep 284 0000015F E977FFFFFF jmp waitforkey 285 _4: 286 00000164 80FC4D cmp ah, 4Dh 287 00000167 7522 jne short _5 288 289 ; right arrow 290 00000169 A1[E8930000] mov eax, [radius] 291 0000016E 0305[F4930000] add eax, [_x0] 292 00000174 3DFF030000 cmp eax, 1023 293 00000179 73DF jnb short _3_ 294 0000017B E80A030000 call black_circle ; clear current position 295 00000180 FF05[F4930000] inc dword [_x0] 296 00000186 E94BFFFFFF jmp _0 ; draw 297 _5: 298 0000018B 80FC50 cmp ah, 50h 299 0000018E 7522 jne short _6 300 ; down arrow 301 00000190 A1[E8930000] mov eax, [radius] 302 00000195 0305[F8930000] add eax, [_y0] 303 0000019B 3DFF020000 cmp eax, 767 304 000001A0 73B8 jnb short _3_ 305 000001A2 E8E3020000 call black_circle ; clear current position 306 000001A7 FF05[F8930000] inc dword [_y0] 307 000001AD E924FFFFFF jmp _0 ; draw 308 _6: 309 000001B2 80FC48 cmp ah, 48h 310 000001B5 751D jne short _7 311 ; up arrow 312 000001B7 A1[E8930000] mov eax, [radius] 313 000001BC 3B05[F8930000] cmp eax, [_y0] 314 000001C2 7396 jnb short _3_ 315 000001C4 E8C1020000 call black_circle ; clear current position 316 000001C9 FF0D[F8930000] dec dword [_y0] 317 000001CF E902FFFFFF jmp _0 ; draw 318 _7: 319 000001D4 80FC47 cmp ah, 47h ; Home key 320 000001D7 750F jne short _8 321 000001D9 E8AC020000 call black_circle ; clear current position 322 000001DE E8BD020000 call beep 323 000001E3 E9ACFEFFFF jmp reset_diameter 324 ; reset diameter, move to center 325 _8: 326 000001E8 80FC4F cmp ah, 4Fh ; End key 327 000001EB 750F jne short _9 328 000001ED E898020000 call black_circle ; clear current position 329 000001F2 E8A9020000 call beep 330 000001F7 E991FEFFFF jmp reset_color 331 ; reset color and diameter, move to center 332 _9: 333 000001FC 663D0D1C cmp ax, 1C0Dh 334 00000200 7509 jne short _10 335 00000202 8005[F0930000]04 add byte [color], 4 336 00000209 EB34 jmp short _14 337 _10: 338 0000020B 80FC53 cmp ah, 53h ; INSERT 339 0000020E 7509 jne short _11 340 00000210 8005[E6930000]04 add byte [tcolor], 4 341 00000217 EB26 jmp short _14 342 _11: 343 00000219 80FC52 cmp ah, 52h ; DEL 344 0000021C 7509 jne short _12 345 0000021E 802D[E6930000]04 sub byte [tcolor], 4 346 00000225 EB18 jmp short _14 347 _12: 348 00000227 80FC49 cmp ah, 49h ; Page UP 349 0000022A 7508 jne short _13 350 0000022C FE0D[F0930000] dec byte [color] 351 00000232 EB0B jmp short _14 352 _13: 353 00000234 80FC51 cmp ah, 51h ; Page Down 354 00000237 7510 jne short _15 355 00000239 FE05[F0930000] inc byte [color] 356 _14: 357 0000023F E85C020000 call beep 358 00000244 E98DFEFFFF jmp _0 359 _15: 360 00000249 E98DFEFFFF jmp waitforkey 361 362 print_msg: 363 0000024E B40E mov ah, 0Eh 364 00000250 BB07000000 mov ebx, 7 365 ;mov bl, 7 ; char attribute & color 366 p_next_chr: 367 00000255 AC lodsb 368 00000256 08C0 or al, al 369 00000258 7404 jz short p_retn ; retn 370 0000025A CD31 int 31h 371 0000025C EBF7 jmp short p_next_chr 372 p_retn: 373 0000025E C3 retn 374 375 drawcircle: 376 ; INPUT: 377 ; [_x0] 378 ; [_y0] 379 ; [radius] 380 ; [color] 381 ; 382 ; Modified registers: esi, edi, eax, ecx, ebx, edx 383 384 ; write circle parameters to left top corner 385 0000025F E838030000 call print_diameter 386 00000264 E86A020000 call print_origin 387 388 ; set pixel pointer position to start of circle buffer 389 00000269 B8[08980000] mov eax, circlebuffer 390 0000026E A3[04980000] mov [pixelpos], eax 391 _dc_ph0: 392 ; quarter 1 393 ; start from y = 0, x = radius 394 00000273 31C0 xor eax, eax 395 00000275 A3[00940000] mov [_y1], eax ; 0 396 0000027A A2[E7930000] mov [phase], al ; 0 397 0000027F 8B2D[E8930000] mov ebp, [radius] 398 00000285 892D[FC930000] mov [_x1], ebp ; y = 0, x = r 399 0000028B BE[04940000] mov esi, _fx 400 _dc_ph0_n: 401 00000290 FF0D[FC930000] dec dword [_x1] 402 00000296 AD lodsd 403 _dc_ph0_x: 404 00000297 8B15[00940000] mov edx, [_y1] 405 0000029D 42 inc edx 406 0000029E 39C2 cmp edx, eax 407 000002A0 7314 jnb short _dc_ph0_y 408 000002A2 50 push eax 409 000002A3 8915[00940000] mov [_y1], edx 410 000002A9 E862010000 call get_start_offset 411 000002AE E83A010000 call write_pixel 412 000002B3 58 pop eax 413 000002B4 EBE1 jmp short _dc_ph0_x 414 _dc_ph0_y: 415 000002B6 A3[00940000] mov [_y1], eax 416 000002BB E850010000 call get_start_offset 417 000002C0 E828010000 call write_pixel 418 000002C5 4D dec ebp 419 000002C6 75C8 jnz short _dc_ph0_n 420 _dc_ph1: 421 ; quarter 2 422 ; start from y = radius, x = 0 423 000002C8 FE05[E7930000] inc byte [phase] 424 000002CE 31C0 xor eax, eax 425 000002D0 A3[FC930000] mov [_x1], eax ; 0 426 000002D5 8B2D[E8930000] mov ebp, [radius] 427 000002DB 892D[00940000] mov [_y1], ebp ; y = r, x = 0 428 000002E1 BE[04940000] mov esi, _fx 429 _dc_ph1_n: 430 000002E6 FF0D[00940000] dec dword [_y1] 431 000002EC AD lodsd 432 _dc_ph1_x: 433 000002ED 8B15[FC930000] mov edx, [_x1] 434 000002F3 42 inc edx 435 000002F4 39C2 cmp edx, eax 436 000002F6 7314 jnb short _dc_ph1_y 437 000002F8 50 push eax 438 000002F9 8915[FC930000] mov [_x1], edx 439 000002FF E80C010000 call get_start_offset 440 00000304 E8E4000000 call write_pixel 441 00000309 58 pop eax 442 0000030A EBE1 jmp short _dc_ph1_x 443 _dc_ph1_y: 444 0000030C A3[FC930000] mov [_x1], eax 445 00000311 E8FA000000 call get_start_offset 446 00000316 E8D2000000 call write_pixel 447 0000031B 4D dec ebp 448 0000031C 75C8 jnz short _dc_ph1_n 449 _dc_ph2: 450 ; quarter 3 451 ; start from y = 0, x = radius 452 0000031E FE05[E7930000] inc byte [phase] 453 00000324 31C0 xor eax, eax 454 00000326 A3[00940000] mov [_y1], eax ; 0 455 0000032B 8B2D[E8930000] mov ebp, [radius] 456 00000331 892D[FC930000] mov [_x1], ebp ; y = 0, x = r 457 00000337 BE[04940000] mov esi, _fx 458 _dc_ph2_n: 459 0000033C FF0D[FC930000] dec dword [_x1] 460 00000342 AD lodsd 461 _dc_ph2_x: 462 00000343 8B15[00940000] mov edx, [_y1] 463 00000349 42 inc edx 464 0000034A 39C2 cmp edx, eax 465 0000034C 7314 jnb short _dc_ph2_y 466 0000034E 50 push eax 467 0000034F 8915[00940000] mov [_y1], edx 468 00000355 E8B6000000 call get_start_offset 469 0000035A E88E000000 call write_pixel 470 0000035F 58 pop eax 471 00000360 EBE1 jmp short _dc_ph2_x 472 _dc_ph2_y: 473 00000362 A3[00940000] mov [_y1], eax 474 00000367 E8A4000000 call get_start_offset 475 0000036C E87C000000 call write_pixel 476 00000371 4D dec ebp 477 00000372 75C8 jnz short _dc_ph2_n 478 _dc_ph3: 479 ; quarter 4 480 ; start from y = radius, x = 0 481 00000374 FE05[E7930000] inc byte [phase] 482 0000037A 31C0 xor eax, eax 483 0000037C A3[FC930000] mov [_x1], eax ; 0 484 00000381 8B2D[E8930000] mov ebp, [radius] 485 00000387 892D[00940000] mov [_y1], ebp ; y = r, x = 0 486 0000038D BE[04940000] mov esi, _fx 487 _dc_ph3_n: 488 00000392 FF0D[00940000] dec dword [_y1] 489 00000398 AD lodsd 490 _dc_ph3_x: 491 00000399 8B15[FC930000] mov edx, [_x1] 492 0000039F 42 inc edx 493 000003A0 39C2 cmp edx, eax 494 000003A2 7314 jnb short _dc_ph3_y 495 000003A4 50 push eax 496 000003A5 8915[FC930000] mov [_x1], edx 497 000003AB E860000000 call get_start_offset 498 000003B0 E838000000 call write_pixel 499 000003B5 58 pop eax 500 000003B6 EBE1 jmp short _dc_ph3_x 501 _dc_ph3_y: 502 000003B8 A3[FC930000] mov [_x1], eax 503 000003BD E84E000000 call get_start_offset 504 000003C2 E826000000 call write_pixel 505 000003C7 4D dec ebp 506 000003C8 75C8 jnz short _dc_ph3_n 507 _dc_ph4: 508 write_circle: 509 000003CA BE[08980000] mov esi, circlebuffer 510 000003CF 8B15[04980000] mov edx, [pixelpos] 511 000003D5 29F2 sub edx, esi 512 000003D7 C1EA02 shr edx, 2 ; / 4 513 ; edx = pixel count 514 ; esi = user's single color pixel buffer address 515 sys _video, 0305h, [color] 515 <1> 515 <1> 515 <1> 515 <1> 515 <1> %if %0 >= 2 515 000003DA BB05030000 <1> mov ebx, %2 515 <1> %if %0 >= 3 515 000003DF 8B0D[F0930000] <1> mov ecx, %3 515 <1> %if %0 = 4 515 <1> mov edx, %4 515 <1> %endif 515 <1> %endif 515 <1> %endif 515 000003E5 B81F000000 <1> mov eax, %1 515 <1> 515 000003EA CD40 <1> int 40h 516 517 000003EC C3 retn 518 519 write_pixel: 520 ; eax = (screen) pixel position 521 000003ED 8B3D[04980000] mov edi, [pixelpos] ; pointer 522 000003F3 AB stosd 523 000003F4 893D[04980000] mov [pixelpos], edi ; pointer 524 000003FA C3 retn 525 526 movecenter: 527 000003FB C705[F4930000]0002- mov dword [_x0], 1024/2 527 00000403 0000 528 00000405 C705[F8930000]8001- mov dword [_y0], 768/2 528 0000040D 0000 529 0000040F C3 retn 530 531 get_start_offset: 532 00000410 B800040000 mov eax, 1024 533 00000415 8B15[F8930000] mov edx, [_y0] 534 0000041B 803D[E7930000]00 cmp byte [phase], 0 535 00000422 7715 ja short gso_1 536 gso_0: 537 ; quarter 1 538 00000424 2B15[00940000] sub edx, [_y1] ; y = 0 -> r 539 0000042A F7E2 mul edx 540 0000042C 0305[F4930000] add eax, [_x0] 541 00000432 0305[FC930000] add eax, [_x1] ; x = r -> 0 542 00000438 C3 retn 543 gso_1: 544 00000439 803D[E7930000]01 cmp byte [phase], 1 545 00000440 7715 ja short gso_2 546 ; quarter 2 547 00000442 2B15[00940000] sub edx, [_y1] ; y = r -> 0 548 00000448 F7E2 mul edx 549 0000044A 0305[F4930000] add eax, [_x0] 550 00000450 2B05[FC930000] sub eax, [_x1] ; x = 0 -> -r 551 00000456 C3 retn 552 gso_2: 553 00000457 803D[E7930000]02 cmp byte [phase], 2 554 0000045E 7715 ja short gso_3 555 ; quarter 3 556 00000460 0315[00940000] add edx, [_y1] ; y = 0 -> -r 557 00000466 F7E2 mul edx 558 00000468 0305[F4930000] add eax, [_x0] 559 0000046E 2B05[FC930000] sub eax, [_x1] ; x = -r -> 0 560 00000474 C3 retn 561 gso_3: 562 ; quarter 4 563 00000475 0315[00940000] add edx, [_y1] ; y = -r -> 0 564 0000047B F7E2 mul edx 565 0000047D 0305[F4930000] add eax, [_x0] 566 00000483 0305[FC930000] add eax, [_x1] ; x = 0 -> r 567 00000489 C3 retn 568 569 black_circle: 570 0000048A 30E4 xor ah, ah 571 0000048C 8625[F0930000] xchg [color], ah ; color = 0 572 00000492 50 push eax 573 00000493 E8C7FDFFFF call drawcircle 574 00000498 58 pop eax 575 00000499 8625[F0930000] xchg [color], ah ; restore color 576 0000049F C3 retn 577 578 beep: 579 ; call beep function (16/64 second, 886Hz) 580 sys _audio, 16, 1331 580 <1> 580 <1> 580 <1> 580 <1> 580 <1> %if %0 >= 2 580 000004A0 BB10000000 <1> mov ebx, %2 580 <1> %if %0 >= 3 580 000004A5 B933050000 <1> mov ecx, %3 580 <1> %if %0 = 4 580 <1> mov edx, %4 580 <1> %endif 580 <1> %endif 580 <1> %endif 580 000004AA B820000000 <1> mov eax, %1 580 <1> 580 000004AF CD40 <1> int 40h 581 000004B1 C3 retn 582 583 get_squareroot: 584 ; input: edx = square of the number (y) 585 ; output: eax = approx. square root of ebx 586 000004B2 BE[D88F0000] mov esi, _squares 587 000004B7 53 push ebx 588 000004B8 31DB xor ebx, ebx 589 ;mov ecx, 256 590 000004BA 8B0D[E8930000] mov ecx, [radius] ; max. value of radius is 256 591 q_sr_x: 592 000004C0 AD lodsd 593 000004C1 39D0 cmp eax, edx 594 000004C3 7303 jnb short q_sr_ok 595 000004C5 43 inc ebx 596 000004C6 E2F8 loop q_sr_x 597 q_sr_ok: 598 000004C8 89D8 mov eax, ebx 599 000004CA 5B pop ebx 600 000004CB C3 retn 601 602 set_text_mode: 603 000004CC 30E4 xor ah, ah 604 000004CE B003 mov al, 3 605 ;int 10h ; al = 03h text mode, int 10 video 606 000004D0 CD31 int 31h ; TRDOS 386 - Video interrupt 607 000004D2 C3 retn 608 609 print_origin: 610 000004D3 803D[E6930000]00 cmp byte [tcolor], 0 611 000004DA 7707 ja short p_o_0 612 000004DC C605[E6930000]8E mov byte [tcolor], 142 613 p_o_0: 614 000004E3 A1[F4930000] mov eax, [_x0] 615 000004E8 3B05[DC930000] cmp eax, [prevx] 616 000004EE 7452 je short _p_o_y 617 ; same x value don't write 618 000004F0 50 push eax ; current x (abscissa) value 619 000004F1 A0[E6930000] mov al, [tcolor] 620 000004F6 A2[E5930000] mov [pcolor], al 621 000004FB C605[E6930000]00 mov byte [tcolor], 0 ; blank (black color) 622 00000502 E810000000 call p_o_1 ; erase/blank previous text 623 00000507 A0[E5930000] mov al, [pcolor] 624 0000050C A2[E6930000] mov [tcolor], al 625 00000511 8F05[DC930000] pop dword [prevx] ; cur -> prev x (abscissa) value 626 p_o_1: 627 00000517 BD[77060000] mov ebp, txt_x0 628 0000051C BE08002C00 mov esi, 002C0008h ; row 44, column 8 629 00000521 E8DF000000 call p_d_x 630 00000526 A1[DC930000] mov eax, [prevx] ; [_x0] 631 0000052B BF[7C060000] mov edi, val_x0 632 00000530 E802010000 call num_to_txt 633 00000535 C60720 mov byte [edi], " " ; blank 634 00000538 BD[7C060000] mov ebp, val_x0 635 0000053D E8C3000000 call p_d_x 636 _p_o_y: 637 00000542 A1[F8930000] mov eax, [_y0] 638 00000547 3B05[E0930000] cmp eax, [prevy] 639 0000054D 744C je short _p_o_y_ok 640 ; same y value don't write 641 0000054F 50 push eax ; current y (ordinate) value 642 00000550 A0[E6930000] mov al, [tcolor] 643 00000555 A2[E5930000] mov [pcolor], al 644 0000055A C605[E6930000]00 mov byte [tcolor], 0 ; blank (black color) 645 00000561 E810000000 call p_o_2 ; erase/blank previous text 646 00000566 A0[E5930000] mov al, [pcolor] 647 0000056B A2[E6930000] mov [tcolor], al 648 00000570 8F05[E0930000] pop dword [prevy] ; cur -> prev y (ordinate) value 649 p_o_2: 650 00000576 BD[82060000] mov ebp, txt_y0 651 0000057B BE08005000 mov esi, 00500008h ; row 80, column 8 652 00000580 E880000000 call p_d_x 653 00000585 A1[E0930000] mov eax, [prevy] ; [_y0] 654 0000058A BF[87060000] mov edi, val_y0 655 0000058F E8A3000000 call num_to_txt 656 00000594 BD[87060000] mov ebp, val_y0 657 00000599 EB6A jmp short p_d_x 658 _p_o_y_ok: 659 0000059B C3 retn 660 661 print_diameter: 662 0000059C 803D[E6930000]00 cmp byte [tcolor], 0 663 000005A3 7707 ja short p_d_0 664 000005A5 C605[E6930000]8E mov byte [tcolor], 142 665 p_d_0: 666 000005AC A1[E8930000] mov eax, [radius] 667 000005B1 D1E0 shl eax, 1 668 000005B3 3B05[D8930000] cmp eax, [prevd] 669 000005B9 747B je short p_d_x_ok 670 ; same diameter don't write 671 000005BB 50 push eax ; current diameter 672 000005BC A0[E6930000] mov al, [tcolor] 673 000005C1 A2[E5930000] mov [pcolor], al 674 000005C6 C605[E6930000]00 mov byte [tcolor], 0 ; blank (black color) 675 000005CD E810000000 call p_d_1 ; erase/blank previous text 676 000005D2 A0[E5930000] mov al, [pcolor] 677 000005D7 A2[E6930000] mov [tcolor], al 678 000005DC 8F05[D8930000] pop dword [prevd] ; cur -> prev diameter 679 p_d_1: 680 000005E2 BD[61060000] mov ebp, txt_diameter 681 000005E7 BE08000800 mov esi, 00080008h ; row 8, column 8 682 000005EC E814000000 call p_d_x 683 000005F1 A1[D8930000] mov eax, [prevd] ; diameter 684 000005F6 BF[6C060000] mov edi, val_diameter 685 000005FB E837000000 call num_to_txt 686 00000600 BD[6C060000] mov ebp, val_diameter 687 ;jmp short p_d_x 688 p_d_x: 689 p_d_x_n: 690 00000605 31D2 xor edx, edx 691 00000607 8A5500 mov dl, [ebp] 692 0000060A 20D2 and dl, dl 693 0000060C 7428 jz short p_d_x_ok 694 0000060E C1E207 shl edx, 7 ; * 128 (for 32x32 user font) 695 00000611 BF[D8070000] mov edi, fontbuff2 ; start of user font data 696 00000616 01D7 add edi, edx 697 698 ;; NOTE: Following system call writes fonts at 699 ;; Std VGA video memory 0A0000h, BL bit 7 selects 700 ;; screen width as 640 pixels (instead of 320 pixels) 701 ;; so 8Fh is sub function 0Fh (write char) 702 ;; with 640 pixels screen witdh. 703 ;; (Even if VESA VBE mode -LFB- is in use, QEMU and 704 ;; a real computer with NVIDIA GEFORCE FX 550 uses 705 ;; A0000h, so.. even if fonts are written at A0000h-B0000h 706 ;; region, the text is appeared on screen 707 ;; while LFB is at C0000000h or E0000000h.) 708 709 ;sys _video, 018Fh, [tcolor], 8005h 710 ;; use STD VGA video memory 711 ;; (0A0000h) 712 sys _video, 020Fh, [tcolor], 8006h ; 32x32 user font 712 <1> 712 <1> 712 <1> 712 <1> 712 <1> %if %0 >= 2 712 00000618 BB0F020000 <1> mov ebx, %2 712 <1> %if %0 >= 3 712 0000061D 8B0D[E6930000] <1> mov ecx, %3 712 <1> %if %0 = 4 712 00000623 BA06800000 <1> mov edx, %4 712 <1> %endif 712 <1> %endif 712 <1> %endif 712 00000628 B81F000000 <1> mov eax, %1 712 <1> 712 0000062D CD40 <1> int 40h 713 ; use LFB for current VBE mode 714 ; for writing fonts on screen 715 0000062F 45 inc ebp 716 00000630 6683C622 add si, 34 ; next char pos 717 00000634 EBCF jmp short p_d_x_n 718 p_d_x_ok: 719 00000636 C3 retn 720 721 num_to_txt: 722 ; eax = number 723 ; edi = digit position 724 ;and eax, 999 725 00000637 83F863 cmp eax, 99 726 0000063A 770C ja short numtxt_0 727 0000063C C60730 mov byte [edi], "0" 728 0000063F 47 inc edi 729 00000640 3C09 cmp al, 9 730 00000642 7704 ja short numtxt_0 731 00000644 C60730 mov byte [edi], "0" 732 00000647 47 inc edi 733 numtxt_0: 734 00000648 B90A000000 mov ecx, 10 735 0000064D 89E5 mov ebp, esp 736 numtxt_1: 737 0000064F 29D2 sub edx, edx 738 00000651 F7F1 div ecx 739 00000653 52 push edx 740 00000654 09C0 or eax, eax 741 00000656 75F7 jnz short numtxt_1 742 numtxt_2: 743 00000658 58 pop eax 744 00000659 0430 add al, "0" 745 0000065B AA stosb 746 0000065C 39EC cmp esp, ebp 747 0000065E 72F8 jb short numtxt_2 748 00000660 C3 retn 749 750 circle_parameters: 751 ;db "Diameter: 510 pixels", 0Dh, 0Ah 752 ;db "x0: 512", 0Dh, 0Ah 753 ;db "y0: 384", 0Dh, 0Ah, 0 754 txt_diameter: 755 00000661 4469616D657465723A- db "Diameter: ", 0 755 0000066A 2000 756 val_diameter: 757 0000066C 30303020706978656C- db "000 pixels", 0 757 00000675 7300 758 00000677 78303A2000 txt_x0: db "x0: ", 0 759 0000067C 303030200000 val_x0: db "000 ", 0, 0 760 00000682 79303A2000 txt_y0: db "y0: ", 0 761 00000687 3030302000 val_y0: db "000 ", 0 762 763 program_msg: 764 0000068C 5452444F5320333836- db "TRDOS 386 v2.0.3 - ('sysvideo') Test Program - Draw Circle" 764 00000695 2076322E302E33202D- 764 0000069E 202827737973766964- 764 000006A7 656F27292054657374- 764 000006B0 2050726F6772616D20- 764 000006B9 2D2044726177204369- 764 000006C2 72636C65 765 000006C6 0D0A db 0Dh, 0Ah 766 000006C8 6279204572646F6761- db "by Erdogan Tan - 18/02/2021" 766 000006D1 6E2054616E202D2031- 766 000006DA 382F30322F32303231 767 ;db 0Dh, 0Ah, 0 768 000006E3 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 769 770 000006E7 557365204172726F77- db "Use Arrow Keys, Home, End to move the CIRCLE .." 770 000006F0 204B6579732C20486F- 770 000006F9 6D652C20456E642074- 770 00000702 6F206D6F7665207468- 770 0000070B 6520434952434C4520- 770 00000714 2E2E 771 00000716 0D0A db 0Dh, 0Ah 772 00000718 557365202B2C2D206B- db "Use +,- keys to increase and decrease DIAMETER .." 772 00000721 65797320746F20696E- 772 0000072A 63726561736520616E- 772 00000733 642064656372656173- 772 0000073C 65204449414D455445- 772 00000745 52202E2E 773 00000749 0D0A db 0Dh, 0Ah 774 0000074B 55736520454E544552- db "Use ENTER key to draw CIRCLE .." 774 00000754 206B657920746F2064- 774 0000075D 72617720434952434C- 774 00000766 45202E2E 775 0000076A 0D0A db 0Dh, 0Ah 776 0000076C 557365205350414345- db "Use SPACE, Pg Up, Pg Down keys to change COLOR .." 776 00000775 2C2050672055702C20- 776 0000077E 506720446F776E206B- 776 00000787 65797320746F206368- 776 00000790 616E676520434F4C4F- 776 00000799 52202E2E 777 0000079D 0D0A db 0Dh, 0Ah 778 0000079F 507265737320455343- db "Press ESC to exit .." 778 000007A8 20746F206578697420- 778 000007B1 2E2E 779 000007B3 0D0A db 0Dh, 0Ah 780 000007B5 0D0A db 0Dh, 0Ah 781 000007B7 507265737320616E79- db "Press any key to continue .." 781 000007C0 206B657920746F2063- 781 000007C9 6F6E74696E7565202E- 781 000007D2 2E 782 nextline: 783 000007D3 0D0A00 db 0Dh, 0Ah, 0 784 bss: 785 786 ABSOLUTE bss 787 788 000007D6 alignb 4 789 790 bss_start: 791 fontbuff2: 792 000007D8 resb 4*256*32 ; 32x32 font data (modif. from 8x8) 793 fontbuff1: 794 000087D8 resb 256*8 ; 8x8 font data (from system) 795 _squares: 796 00008FD8 resd 256 ; squares of numbers from 0 t0 255 797 000093D8 prevd: resd 1 798 000093DC prevx: resd 1 799 000093E0 prevy resd 1 800 counter: 801 000093E4 resb 1 802 000093E5 pcolor: resb 1 ; previous (saved) text color 803 000093E6 tcolor: resb 1 ; text color 804 000093E7 phase: resb 1 ; circle phase (quarter) 805 000093E8 radius: resd 1 ; current radius value 806 000093EC _r2: resd 1 ; square of R 807 000093F0 color: resd 1 ; circle color 808 000093F4 _x0: resd 1 ; circle origin, x-axis 809 000093F8 _y0: resd 1 ; cirle origin, y-axis 810 000093FC _x1: resd 1 ; recent value of abscissa 811 00009400 _y1: resd 1 ; recent value of ordinate 812 00009404 _fx: resd 256 ; for every X values from 0 to 255 813 pixelpos: 814 00009804 resd 1 815 circlebuffer: 816 00009808 resd 57600 ; 240*240*4 bytes 817 bss_end: