Jump to content

Recommended Posts

I did not want to hijack this thread -

I am referring to COMPUTE! July 1983 - Circles (https://www.atarimagazines.com/compute/issue38/066_1_CIRCLES.php)

 

I typed in (yes, I really did type it in) the assembly language version of the circle algorithm.  I double checked it and it still doesn't work.  I tried 400/800 OSB with BASIC Rev A as well as a 130XE with BASIC REV C, and Altirra 1.57.  None work.  I also typed in Program 5: Potential - all it did was plot 3 points.  I have not had the time to go through the disassembly.  Wondering if anyone has got this to work, found an addendum to this article?

 

Paste this into Altirra

 
10 REM 28000 - IS SUBROUTINE
20 GOSUB 28000
100 REM CIRCLE DEMONSTRATION
110 REM PROGRAM #6
140 REM THIS METHOD TAKES APPROXIMATELY 0.1833 SECONDS
210 GRAPHICS 8
220 COLOR 1
230 SETCOLOR 2,0,0
240 A=160
250 B=80
260 R=50
270 P=7*16*16*16
300 I=USR(P,A,B,R,1)
310 END
28000 FOR I=0 TO 758:READ A:POKE 28672+I,A:NEXT I
28010 RETURN
28672 DATA 104,104,141,5,6,104
28678 DATA 141,4,6,104,141,7
28684 DATA 6,104,141,6,6,104
28690 DATA 141,9,6,141,12,6
28696 DATA 104,141,8,6,141,11
28702 DATA 6,104,104,141,10,6
28708 DATA 201,3,144,1,96,169
28714 DATA 0,141,13,6,141,14
28720 DATA 6,141,15,6,141,16
28726 DATA 6,24,173,4,6,109
28732 DATA 11,6,141,25,6,173
28738 DATA 5,6,109,12,6,141
28744 DATA 26,6,24,173,4,6
28750 DATA 109,13,6,141,29,6
28756 DATA 173,5,6,109,14,6
28762 DATA 141,30,6,56,173,4
28768 DATA 6,237,11,6,141,27
28774 DATA 6,173,5,6,237,12
28780 DATA 6,141,28,6,56,173
28786 DATA 4,6,237,13,6,141
28792 DATA 31,6,173,5,6,141
28798 DATA 14,6,141,32,6,24
28804 DATA 173,6,6,109,11,6
28810 DATA 141,33,6,173,7,6
28816 DATA 109,12,6,141,34,6
28822 DATA 24,173,6,6,109,13
28828 DATA 6,141,37,6,173,7
28834 DATA 6,109,14,6,141,38
28840 DATA 6,56,173,6,6,237
28846 DATA 11,6,141,35,6,173
28852 DATA 7,6,237,12,6,141
28858 DATA 36,6,56,173,6,6
28864 DATA 237,13,6,141,39,6
28870 DATA 173,7,6,237,14,6
28876 DATA 141,40,6,173,25,6
28882 DATA 141,0,6,173,26,6
28888 DATA 141,1,6,173,37,6
28894 DATA 141,2,6,173,38,6
28900 DATA 141,3,6,32,106,114
28906 DATA 173,27,6,141,0,6
28912 DATA 173,28,6,141,1,6
28918 DATA 32,106,114,173,25,6
28924 DATA 141,0,6,173,26,6
28930 DATA 141,1,6,173,39,6
28936 DATA 141,2,6,173,40,6
28942 DATA 141,3,6,32,106,114
28948 DATA 173,27,6,141,0,6
28954 DATA 173,28,6,141,1,6
28960 DATA 32,106,114,173,29,6
28966 DATA 141,0,6,173,30,6
28972 DATA 141,1,6,173,33,6
28978 DATA 141,2,6,173,34,6
28984 DATA 141,3,6,32,106,114
28990 DATA 173,31,6,141,0,6
28996 DATA 173,32,6,141,1,6
29002 DATA 32,106,114,173,29,6
29008 DATA 141,0,6,173,30,6
29014 DATA 141,1,6,173,35,6
29020 DATA 141,2,6,173,36,6
29026 DATA 141,3,6,32,106,114
29032 DATA 173,31,6,141,0,6
29038 DATA 173,32,6,141,1,6
29044 DATA 32,106,114,173,14,6
29050 DATA 205,12,6,240,3,144
29056 DATA 10,96,173,13,6,205
29062 DATA 11,6,144,1,96,173
29068 DATA 11,6,133,4,173,12
29074 DATA 6,133,5,173,13,6
29080 DATA 133,205,173,14,6,133
29086 DATA 206,6,4,38,5,6
29092 DATA 205,38,206,56,165,205
29098 DATA 109,15,6,141,17,6
29104 DATA 165,206,109,16,6,141
29110 DATA 18,6,24,173,17,6
29116 DATA 229,4,141,19,6,173
29122 DATA 18,6,229,5,141,20
29128 DATA 6,173,18,6,16,27
29134 DATA 73,255,141,22,6,173
29140 DATA 17,6,73,255,24,105
29146 DATA 1,141,21,6,173,22
29152 DATA 6,105,0,141,22,6
29158 DATA 24,144,9,141,22,6
29164 DATA 173,17,6,141,21,6
29170 DATA 173,20,6,16,27,73
29176 DATA 255,141,24,6,173,19
29182 DATA 6,73,255,24,105,1
29188 DATA 141,23,6,173,24,6
29194 DATA 105,0,141,24,6,24
29200 DATA 144,9,141,24,6,173
29206 DATA 19,6,141,23,6,173
29212 DATA 17,6,141,15,6,173
29218 DATA 18,6,141,16,6,24
29224 DATA 173,13,6,105,1,141
29230 DATA 13,6,173,14,6,105
29236 DATA 0,141,14,6,173,22
29242 DATA 6,205,24,6,144,39
29248 DATA 208,8,173,21,6,205
29254 DATA 23,6,144,29,173,19
29260 DATA 6,141,15,6,173,20
29266 DATA 6,141,16,6,56,173
29272 DATA 11,6,233,1,141,11
29278 DATA 6,173,12,6,233,0
29284 DATA 141,12,6,76,55,112
29290 DATA 173,2,6,133,205,169
29296 DATA 0,133,206,6,205,38
29302 DATA 206,6,205,38,206,6
29308 DATA 205,38,206,165,205,133
29314 DATA 4,165,206,133,5,6
29320 DATA 205,38,206,6,205,38
29326 DATA 206,24,165,205,101,4
29332 DATA 133,205,165,206,101,5
29338 DATA 133,206,173,0,6,133
29344 DATA 4,173,1,6,133,5
29350 DATA 70,5,102,4,70,5
29356 DATA 102,4,70,5,102,4
29362 DATA 24,165,205,101,4,133
29368 DATA 205,165,206,101,5,133
29374 DATA 206,24,165,205,101,88
29380 DATA 133,205,165,206,101,89
29386 DATA 133,206,173,0,6,41
29392 DATA 7,170,160,0,173,10
29398 DATA 6,208,10,189,41,6
29404 DATA 73,255,49,205,145,205
29410 DATA 96,201,1,208,8,189
29416 DATA 41,6,17,205,145,205
29422 DATA 96,189,41,6,81,205
29428 DATA 145,205,96,0,0,0

Disassembly:

7000: 68                PLA
7001: 68                PLA
7002: 8D 05 06          STA $0605
7005: 68                PLA
7006: 8D 04 06          STA $0604
7009: 68                PLA
700A: 8D 07 06          STA $0607
700D: 68                PLA
700E: 8D 06 06          STA $0606
7011: 68                PLA
7012: 8D 09 06          STA $0609
7015: 8D 0C 06          STA $060C
7018: 68                PLA
7019: 8D 08 06          STA $0608
701C: 8D 0B 06          STA $060B
701F: 68                PLA
7020: 68                PLA
7021: 8D 0A 06          STA $060A
7024: C9 03             CMP #$03
7026: 90 01             BCC $7029
7028: 60                RTS
7029: A9 00             LDA #$00
702B: 8D 0D 06          STA $060D
702E: 8D 0E 06          STA $060E
7031: 8D 0F 06          STA $060F
7034: 8D 10 06          STA $0610
7037: 18                CLC
7038: AD 04 06          LDA $0604
703B: 6D 0B 06          ADC $060B
703E: 8D 19 06          STA $0619
7041: AD 05 06          LDA $0605
7044: 6D 0C 06          ADC $060C
7047: 8D 1A 06          STA $061A
704A: 18                CLC
704B: AD 04 06          LDA $0604
704E: 6D 0D 06          ADC $060D
7051: 8D 1D 06          STA $061D
7054: AD 05 06          LDA $0605
7057: 6D 0E 06          ADC $060E
705A: 8D 1E 06          STA $061E
705D: 38                SEC
705E: AD 04 06          LDA $0604
7061: ED 0B 06          SBC $060B
7064: 8D 1B 06          STA $061B
7067: AD 05 06          LDA $0605
706A: ED 0C 06          SBC $060C
706D: 8D 1C 06          STA $061C
7070: 38                SEC
7071: AD 04 06          LDA $0604
7074: ED 0D 06          SBC $060D
7077: 8D 1F 06          STA $061F
707A: AD 05 06          LDA $0605
707D: 8D 0E 06          STA $060E
7080: 8D 20 06          STA $0620
7083: 18                CLC
7084: AD 06 06          LDA $0606
7087: 6D 0B 06          ADC $060B
708A: 8D 21 06          STA $0621
708D: AD 07 06          LDA $0607
7090: 6D 0C 06          ADC $060C
7093: 8D 22 06          STA $0622
7096: 18                CLC
7097: AD 06 06          LDA $0606
709A: 6D 0D 06          ADC $060D
709D: 8D 25 06          STA $0625
70A0: AD 07 06          LDA $0607
70A3: 6D 0E 06          ADC $060E
70A6: 8D 26 06          STA $0626
70A9: 38                SEC
70AA: AD 06 06          LDA $0606
70AD: ED 0B 06          SBC $060B
70B0: 8D 23 06          STA $0623
70B3: AD 07 06          LDA $0607
70B6: ED 0C 06          SBC $060C
70B9: 8D 24 06          STA $0624
70BC: 38                SEC
70BD: AD 06 06          LDA $0606
70C0: ED 0D 06          SBC $060D
70C3: 8D 27 06          STA $0627
70C6: AD 07 06          LDA $0607
70C9: ED 0E 06          SBC $060E
70CC: 8D 28 06          STA $0628
70CF: AD 19 06          LDA $0619
70D2: 8D 00 06          STA $0600
70D5: AD 1A 06          LDA $061A
70D8: 8D 01 06          STA $0601
70DB: AD 25 06          LDA $0625
70DE: 8D 02 06          STA $0602
70E1: AD 26 06          LDA $0626
70E4: 8D 03 06          STA $0603
70E7: 20 6A 72          JSR $726A
70EA: AD 1B 06          LDA $061B
70ED: 8D 00 06          STA $0600
70F0: AD 1C 06          LDA $061C
70F3: 8D 01 06          STA $0601
70F6: 20 6A 72          JSR $726A
70F9: AD 19 06          LDA $0619
70FC: 8D 00 06          STA $0600
70FF: AD 1A 06          LDA $061A
7102: 8D 01 06          STA $0601
7105: AD 27 06          LDA $0627
7108: 8D 02 06          STA $0602
710B: AD 28 06          LDA $0628
710E: 8D 03 06          STA $0603
7111: 20 6A 72          JSR $726A
7114: AD 1B 06          LDA $061B
7117: 8D 00 06          STA $0600
711A: AD 1C 06          LDA $061C
711D: 8D 01 06          STA $0601
7120: 20 6A 72          JSR $726A
7123: AD 1D 06          LDA $061D
7126: 8D 00 06          STA $0600
7129: AD 1E 06          LDA $061E
712C: 8D 01 06          STA $0601
712F: AD 21 06          LDA $0621
7132: 8D 02 06          STA $0602
7135: AD 22 06          LDA $0622
7138: 8D 03 06          STA $0603
713B: 20 6A 72          JSR $726A
713E: AD 1F 06          LDA $061F
7141: 8D 00 06          STA $0600
7144: AD 20 06          LDA $0620
7147: 8D 01 06          STA $0601
714A: 20 6A 72          JSR $726A
714D: AD 1D 06          LDA $061D
7150: 8D 00 06          STA $0600
7153: AD 1E 06          LDA $061E
7156: 8D 01 06          STA $0601
7159: AD 23 06          LDA $0623
715C: 8D 02 06          STA $0602
715F: AD 24 06          LDA $0624
7162: 8D 03 06          STA $0603
7165: 20 6A 72          JSR $726A
7168: AD 1F 06          LDA $061F
716B: 8D 00 06          STA $0600
716E: AD 20 06          LDA $0620
7171: 8D 01 06          STA $0601
7174: 20 6A 72          JSR $726A
7177: AD 0E 06          LDA $060E
717A: CD 0C 06          CMP $060C
717D: F0 03             BEQ $7182
717F: 90 0A             BCC $718B
7181: 60                RTS
7182: AD 0D 06          LDA $060D
7185: CD 0B 06          CMP $060B
7188: 90 01             BCC $718B
718A: 60                RTS
718B: AD 0B 06          LDA $060B
718E: 85 04             STA RAMLO
7190: AD 0C 06          LDA $060C
7193: 85 05             STA RAMLO+1
7195: AD 0D 06          LDA $060D
7198: 85 CD             STA $CD
719A: AD 0E 06          LDA $060E
719D: 85 CE             STA $CE
719F: 06 04             ASL RAMLO
71A1: 26 05             ROL RAMLO+1
71A3: 06 CD             ASL $CD
71A5: 26 CE             ROL $CE
71A7: 38                SEC
71A8: A5 CD             LDA $CD
71AA: 6D 0F 06          ADC $060F
71AD: 8D 11 06          STA $0611
71B0: A5 CE             LDA $CE
71B2: 6D 10 06          ADC $0610
71B5: 8D 12 06          STA $0612
71B8: 18                CLC
71B9: AD 11 06          LDA $0611
71BC: E5 04             SBC RAMLO
71BE: 8D 13 06          STA $0613
71C1: AD 12 06          LDA $0612
71C4: E5 05             SBC RAMLO+1
71C6: 8D 14 06          STA $0614
71C9: AD 12 06          LDA $0612
71CC: 10 1B             BPL $71E9
71CE: 49 FF             EOR #$FF
71D0: 8D 16 06          STA $0616
71D3: AD 11 06          LDA $0611
71D6: 49 FF             EOR #$FF
71D8: 18                CLC
71D9: 69 01             ADC #$01
71DB: 8D 15 06          STA $0615
71DE: AD 16 06          LDA $0616
71E1: 69 00             ADC #$00
71E3: 8D 16 06          STA $0616
71E6: 18                CLC
71E7: 90 09             BCC $71F2
71E9: 8D 16 06          STA $0616
71EC: AD 11 06          LDA $0611
71EF: 8D 15 06          STA $0615
71F2: AD 14 06          LDA $0614
71F5: 10 1B             BPL $7212
71F7: 49 FF             EOR #$FF
71F9: 8D 18 06          STA $0618
71FC: AD 13 06          LDA $0613
71FF: 49 FF             EOR #$FF
7201: 18                CLC
7202: 69 01             ADC #$01
7204: 8D 17 06          STA $0617
7207: AD 18 06          LDA $0618
720A: 69 00             ADC #$00
720C: 8D 18 06          STA $0618
720F: 18                CLC
7210: 90 09             BCC $721B
7212: 8D 18 06          STA $0618
7215: AD 13 06          LDA $0613
7218: 8D 17 06          STA $0617
721B: AD 11 06          LDA $0611
721E: 8D 0F 06          STA $060F
7221: AD 12 06          LDA $0612
7224: 8D 10 06          STA $0610
7227: 18                CLC
7228: AD 0D 06          LDA $060D
722B: 69 01             ADC #$01
722D: 8D 0D 06          STA $060D
7230: AD 0E 06          LDA $060E
7233: 69 00             ADC #$00
7235: 8D 0E 06          STA $060E
7238: AD 16 06          LDA $0616
723B: CD 18 06          CMP $0618
723E: 90 27             BCC $7267
7240: D0 08             BNE $724A
7242: AD 15 06          LDA $0615
7245: CD 17 06          CMP $0617
7248: 90 1D             BCC $7267
724A: AD 13 06          LDA $0613
724D: 8D 0F 06          STA $060F
7250: AD 14 06          LDA $0614
7253: 8D 10 06          STA $0610
7256: 38                SEC
7257: AD 0B 06          LDA $060B
725A: E9 01             SBC #$01
725C: 8D 0B 06          STA $060B
725F: AD 0C 06          LDA $060C
7262: E9 00             SBC #$00
7264: 8D 0C 06          STA $060C
7267: 4C 37 70          JMP $7037
726A: AD 02 06          LDA $0602
726D: 85 CD             STA $CD
726F: A9 00             LDA #$00
7271: 85 CE             STA $CE
7273: 06 CD             ASL $CD
7275: 26 CE             ROL $CE
7277: 06 CD             ASL $CD
7279: 26 CE             ROL $CE
727B: 06 CD             ASL $CD
727D: 26 CE             ROL $CE
727F: A5 CD             LDA $CD
7281: 85 04             STA RAMLO
7283: A5 CE             LDA $CE
7285: 85 05             STA RAMLO+1
7287: 06 CD             ASL $CD
7289: 26 CE             ROL $CE
728B: 06 CD             ASL $CD
728D: 26 CE             ROL $CE
728F: 18                CLC
7290: A5 CD             LDA $CD
7292: 65 04             ADC RAMLO
7294: 85 CD             STA $CD
7296: A5 CE             LDA $CE
7298: 65 05             ADC RAMLO+1
729A: 85 CE             STA $CE
729C: AD 00 06          LDA $0600
729F: 85 04             STA RAMLO
72A1: AD 01 06          LDA $0601
72A4: 85 05             STA RAMLO+1
72A6: 46 05             LSR RAMLO+1
72A8: 66 04             ROR RAMLO
72AA: 46 05             LSR RAMLO+1
72AC: 66 04             ROR RAMLO
72AE: 46 05             LSR RAMLO+1
72B0: 66 04             ROR RAMLO
72B2: 18                CLC
72B3: A5 CD             LDA $CD
72B5: 65 04             ADC RAMLO
72B7: 85 CD             STA $CD
72B9: A5 CE             LDA $CE
72BB: 65 05             ADC RAMLO+1
72BD: 85 CE             STA $CE
72BF: 18                CLC
72C0: A5 CD             LDA $CD
72C2: 65 58             ADC SAVMSC
72C4: 85 CD             STA $CD
72C6: A5 CE             LDA $CE
72C8: 65 59             ADC SAVMSC+1
72CA: 85 CE             STA $CE
72CC: AD 00 06          LDA $0600
72CF: 29 07             AND #$07
72D1: AA                TAX
72D2: A0 00             LDY #$00
72D4: AD 0A 06          LDA $060A
72D7: D0 0A             BNE $72E3
72D9: BD 29 06          LDA $0629,X
72DC: 49 FF             EOR #$FF
72DE: 31 CD             AND ($CD),Y
72E0: 91 CD             STA ($CD),Y
72E2: 60                RTS
72E3: C9 01             CMP #$01
72E5: D0 08             BNE $72EF
72E7: BD 29 06          LDA $0629,X
72EA: 11 CD             ORA ($CD),Y
72EC: 91 CD             STA ($CD),Y
72EE: 60                RTS
72EF: BD 29 06          LDA $0629,X
72F2: 51 CD             EOR ($CD),Y
72F4: 91 CD             STA ($CD),Y

Share this post


Link to post
Share on other sites
Posted (edited)

Hi!

Quote

I did not want to hijack this thread -

I am referring to COMPUTE! July 1983 - Circles (https://www.atarimagazines.com/compute/issue38/066_1_CIRCLES.php)

 

I typed in (yes, I really did type it in) the assembly language version of the circle algorithm.  I double checked it and it still doesn't work.  I tried 400/800 OSB with BASIC Rev A as well as a 130XE with BASIC REV C, and Altirra 1.57.  None work.  I also typed in Program 5: Potential - all it did was plot 3 points.  I have not had the time to go through the disassembly.  Wondering if anyone has got this to work, found an addendum to this article?

 

Try this fixed version: circ.lst

 

Fixed two bugs:

- an "STA" instead of an "SBC" in one assembly instruction

- missing initialization for a table of powers of two.

 

Also, this is the BASIC program, "circle 5", works for me: circ5.lst

 

 

Have Fun!

 

Edited by dmsc
  • Thanks 2

Share this post


Link to post
Share on other sites

This is the routine, working inside "Disc 'o Pop":

; -----------------------------------------------------------------------
; Draws a circle, centered by given point with given radius
; void __fastcall__
; Draw_Circle(Draw_POINTSPAN* pCircleStruct);

.define xOffs			tmp1
.define yOffs			tmp2
.define deviation		tmp3
.define xpx			ptr2
.define xpy			ptr2+1
.define xmx			ptr3
.define xmy			ptr3+1
.define ypx			ptr4
.define ypy			ptr4+1


.export _Draw_Circle
.proc _Draw_Circle
	sta ptr1			; pointer to access vars...
	stx ptr1+1
		
	ldy #2
	lda (ptr1), y		; access radius
	bne ok				; zero length -> plot point...
	jmp _Draw_Point::_Pointer_Setup_Entry
	
ok:	sta xOffs
	sta deviation
	
	lda #0
	sta deviation+1
	sta yOffs
	
	dey
	lda (ptr1),y		; get center y
	tax					; remember this...
	
	sta ypy				; we start with yoffs = 0
	sta ymy
	
	clc
	adc xOffs
	sta ypx
	
	txa					; restore center y
	sec
	sbc xOffs
	sta ymx
	
	dey
	lda (ptr1),y		; get center x
	tax					; remember this...
	
	sta xpy				; we start with yoffs = 0
	sta xmy
	
	clc
	adc xOffs
	sta xpx
	
	txa					; restore center x	
	sec
	sbc xOffs
	sta xmx	

@loop:
	; plot in 8 octants (deferred to avoid eor double plotting!
	
	ldx xpx				
	ldy ypy
	jsr _Draw_Point_XY
	
	ldx xmx				; reuse ypy which is still in ptr1...
	jsr _Draw_Point_XY::RowAdressOk
	
	ldx xpx
	ldy ymy
	jsr _Draw_Point_XY
	
	ldx xmx				; reuse ymy which is still in ptr1...
	jsr _Draw_Point_XY::RowAdressOk
	
	ldx xpy
	ldy ypx
	jsr _Draw_Point_XY

	ldx xmy				; reuse ypx which is still in ptr1...
	jsr _Draw_Point_XY::RowAdressOk	
	
	ldx xpy
	ldy ymx
	jsr _Draw_Point_XY
	
	ldx xmy				; reuse ymx which is still in ptr1...
	jsr _Draw_Point_XY::RowAdressOk		
	
	; y = y + 1

	inc yOffs
	inc xpy;
	inc ypy;
	dec xmy;
	dec ymy;	
	
	; deviation = deviation - y*2 - 1;
	
	lda deviation
	clc			; - 1
	sbc yOffs
	bcs @cont
	dec deviation+1
	sec
@cont:
	sbc yOffs
	sta deviation
	lda deviation+1
	sbc #0				; handle highbyte
	sta deviation+1		; (better than dec here - we reuse this value now...)	
	
	bpl @checkEndCondition
	
	; x = x - 1
	
	dec xOffs
	dec xpx
	dec ypx
	inc xmx
	inc ymx	
	
	; deviation = deviation + x*2 - 1;
	
	lda deviation
	clc
	adc xOffs
	bcc @cont2
	inc deviation+1
	clc
@cont2:
	adc xOffs
	bcc @cont3
	inc deviation+1
	clc
@cont3:
	sbc	#0			; carry clear -> = -1
	sta deviation
	bcs @checkEndCondition
	dec deviation+1
	
@checkEndCondition:

	; while(y<=x)

	lda xOffs
	cmp yOffs
	bcs @loop
	
@leave:
leave:
	rts
.endproc

 

  • Like 4
  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...