home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_25_1988_Transactor_Publishing.d64 / quikpx < prev    next >
Text File  |  2023-02-26  |  3KB  |  97 lines

  1. ;           QUIKPX
  2. ;
  3. ;   This subroutine is designed to
  4. ; light a pixel on a hi-res screen
  5. ; in 114 cycles. This includes six
  6. ; cycles for a JSR to get us here.
  7. ; Values must be sent as follows:
  8. ;
  9. ; a = low x  (0   - 255)
  10. ; x = high x (0 if a<255, else 1)
  11. ; y = y      (0   - 199)
  12. ;
  13. pntr = $fb   ; low core pointer
  14. ;
  15.        *=$8000
  16. ;
  17. ;  first, we save stuff to use later
  18. ;
  19. quikpx pha         ;save low part of x
  20.        tya         ;move row # into a
  21.        pha         ;save row
  22. ;
  23. ; now we use fact that low byte of
  24. ; row offset repeats every 32 bytes
  25. ;
  26.        and #$1f    ;get number range of 0-31
  27.        tay         ;now use as an index
  28.        lda lookup,y ;get lo byte of left column of row
  29.        sta pntr    ;set it up in lowcore
  30. ;
  31. ;  here, we calculate the high byte
  32. ; of the row offset from screen base
  33. ; by munging on the bits in y
  34. ;
  35.        pla         ;get row
  36.        clc         ;make it ok to shift bits
  37.        and #$f8    ;dont move anything into carry
  38.        ror a       ;divide by 2
  39.        ror a       ; ...   by 4
  40.        ror a       ; ...   by 8
  41.        sta pntr+1  ;upper byte of screen offset for y value
  42. ;
  43.        and #$fc    ;to prevent shifts into the carry
  44.        ror a       ;divide by 16
  45.        ror a       ;divide by 32
  46.        adc pntr+1  ;add to upper byte
  47.        sta pntr+1  ;make it official
  48. ;
  49. ; now, we save the bit position we
  50. ; will light up when after we calculate
  51. ; the byte address.
  52. ;
  53.        pla         ;get low byte of x
  54.        tay         ;hold it temporarily
  55.        and #$07    ;these will be the bits to light in byte
  56.        pha         ;save them
  57. ;
  58. ; here, add in the value of the x
  59. ; coordinate.
  60. ;
  61.        tya         ;get back low byte of x
  62.        and #$f8    ;make it a power of 8 (max of 224)
  63.        adc pntr    ;carry still clear, add it
  64.        sta pntr    ;make change official
  65. ;
  66. ; now we add in the base of our
  67. ; hi-res screen
  68. ;
  69.        txa         ;get hi byte of x value
  70.        adc #$20    ;start of hi-res screen--hi byte
  71.        adc pntr+1  ;add to hi byte of offset
  72.        sta pntr+1  ;make it official
  73. ;
  74. ; get back our pixel position, and
  75. ; use it to look up value.
  76. ;
  77.        pla          ;get bit to light in byte
  78.        tax          ;use as index into table of bytes
  79.        lda litbit,x ;get value of byte to use
  80. ;
  81. ; and finally, we are ready to light
  82. ; up that pixel!
  83. ;
  84.        ldy #$00     ;set index = 0
  85.        ora (pntr),y ;create a new byte
  86.        sta (pntr),y ;store it !
  87. ;
  88.        rts         ;jump home
  89. ;
  90. litbit .byte $80,$40,$20,$10,$08,$04,$02,$01
  91. ;
  92. lookup .byte $00,$01,$02,$03,$04,$05,$06,$07
  93.        .byte $40,$41,$42,$43,$44,$45,$46,$47
  94.        .byte $80,$81,$82,$83,$84,$85,$86,$87
  95.        .byte $c0,$c1,$c2,$c3,$c4,$c5,$c6,$c7
  96.        .end
  97.