; program: 16 bit squares test - standard 16 bit / 32 bit result bitshift multiply routine * = $801 byteaddr = $fc ;fc, fd used basic byte 11,8,10,0,158,50,48,54,49,0,0,0 ;program "10 sys 2061" for autostart bmpscreen = $2000 dummy = $0 lda #>bmpscreen ;initialize self-mod code sta mod1+2 lda #bmpscreen sta byteaddr lda yp and #248 beq yp_and_7 ;if (yp and 248) = 0 don't multiply sta temp ;(yp and 248) on temp ;temp is 8 bit only sta temp2+1 ;low byte first lda #$00 ;hi byte of temp is 0 sta temp2 ;temp on temp2 asl temp2+1 rol temp2 ;temp x 2 asl temp2+1 rol temp2 ;now temp x 4 clc lda temp2+1 adc temp sta temp2+1 bcc continue inc temp2 ;now temp x 5 continue asl temp2+1 rol temp2 ;now temp x 10 asl temp2+1 rol temp2 ;now temp x 20 asl temp2+1 rol temp2 ;now temp x 40 ;temp2 now olds (yp and 248) * 40 clc lda byteaddr+1 adc temp2+1 sta byteaddr+1 lda byteaddr adc temp2 sta byteaddr ;byteaddr = byteaddr+40*(yp and 248) yp_and_7 lda yp and #7 sta temp ;(yp and 7) on temp clc lda byteaddr+1 adc temp sta byteaddr+1 sta byteaddr_y+1 ;added bcc x_compute inc byteaddr ;byteaddr = byteaddr+(yp and 7) x_compute lda byteaddr sta byteaddr_y ;added lda xp+1 and #<504 sta temp2+1 lda xp and #>504 sta temp2 ;(xp and 504) on temp2 clc lda byteaddr+1 adc temp2+1 sta byteaddr+1 lda byteaddr adc temp2 sta byteaddr ;byteaddr = byteaddr+(xp and 504) ;part2: turn on bit lda xp+1 and #7 tax ;(xp and 7) on x lda byteaddr ; sta byteaddr+2 ;swap hi-low bytes for indirect indexed lda xp+1 and #7 tay ldx #$00 ;turn on bit lda (byteaddr+1),x ora bit_table,y sta (byteaddr+1),x lda yp sta yp_old ;store yp to check if it has changed before ;plotting next point lda xp sta xp_old lda xp+1 sta xp_old+1 rts ;storage locations for main program loop_counter byte 0 temp_counter byte 0 ;storage locations for plot routine xp byte 0,0 yp byte 0 bit_table byte 128,64,32,16,8,4,2,1 temp byte 0 temp2 byte 0,0 byteaddr_y byte 0,0 yp_old byte 0 xp_old byte 0,0