6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 8:49 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Aug 18, 2005 10:48 am 
Offline

Joined: Tue Aug 02, 2005 9:42 pm
Posts: 19
Location: Poland
Code:
;
; fast textmode putpixel
; (made for c64 but can be used anywhere)
;
;
; it's real fast but takes 50 bytes of zeropage
; for 25 columns screen
; -> good for demos ;-)
;
;
; how does it work:
; on zeropage there are 2byte columns' pointers
; and there is only Y index reg used to determine
; row of pixel
; just like STA ([column*2+zeropageptr]),y
;
; Written from scratch by Rafal Szyja , Poland
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

zeropage= 100 ; zeropage pointer for generating tables

_x= 251   ; x coordinate of
_y= 252   ; y

temp= 99   ; temporary storage
   

   *= $1000
   
   JSR gentab   ; this is called only once for this routine
         ; by altering gentab you can for example make table
         ; for different screen posiotion and organization
         ; than c64's poweron default 40x25 @ 0400

; this is only testpiece - pixels are to be set somewhere else
; and then jump to setpix
   LDA #0
   STA _x
   LDA #10
   STA _y

; real start of routine

setpix   
   LDA _y
   ASL
   CLC   ; y coor will be always < 128 so you can gain 2 cycles by deleting this line
   ADC #100
   sta dest+1   ; program automodification = faster operation
   
   ldy _x
   lda #255   ; just to test routine , there is actual pixelval
dest   
   STA ($00),y   
   rts
   
;---------------------------------------------------------)
   
gentab   ; generates tables with columns' values
   LDA #$00   ; LSB of screen
   LDX #$04   ; MSB of screen
   
   LDY #0
   
loop   
   STA zeropage,y
   INY
   sta temp
   txa
   STa zeropage,y
   lda temp
   INY
   CLC
   ADC #40      ; 40 rows
   BCC _a
   INX
_a   
   CPY #50
   BEQ stop
   jmp loop

stop    
   RTS



and slower variation using only 4 zeropage registers (possibly only 2):

Code:
   *= $1000
   
_x= 251   ; x
_y= 252   ; y
   
dyl = 253   ; destination lo
dyh = 254   ;         hi
   
   LDA #2
   STA _y
   LDA #2
   sta _x
   
   LDA #0
   STA dyh
   LDA _y
   ASL ;A
   ROL dyh
   ASL ;a
   ROL dyh
   CLC
   ADC _y
   BCC x1
   INC dyh
x1
   ASL ;A
   ROL dyh
   ASL ;A
   ROL dyh
   ASL ;A
   ROL dyh
   STA dyl
   
   CLC
   LDA dyh
   ADC #$04
   STA dyh
   
   
   LDY _x   
   LDA #160
   STA (dyl),y
   JMP *

_________________
owns 1xC128, 1x128D cr ,1xc64 (broken unfortunately) ,1xc64c ,2xc64g (one is broken) ,~4xc64e ,1x1541 ,1x1541-II ,1x1541C and some chips for those machines ;-)

www.vulture.c64.org
www.rafalszyja.republika.pl


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: