Prince-of-Persia-Apple-II

A running-jumping-swordfighting game Jordan Mechner made on the Apple II from 1985-89
Log | Files | Refs | README | LICENSE

CUBE.S (2179B)


      1  lst off
      2 
      3 *------------------------------------------------- rotcube
      4 
      5 mainYoffset = 46 ;(192-60)/2
      6 botYoffset = 72
      7 mainXoffset = 68 ;(280-144)/2
      8 
      9 color = $E4
     10 page = $E6
     11 
     12  dum 0
     13 index ds 1
     14 ysave ds 1
     15 yadd ds 1
     16 yoffset ds 1
     17  dend
     18 
     19 *-------------------------------------------------
     20 
     21 rotcube jsr $f3e2 ;hgr
     22  jsr $f3d8 ;hgr2
     23 
     24  lda #1
     25  sta yadd
     26 
     27  sta yoffset
     28 
     29 * Draw on page not showing:
     30 
     31 mainloop lda page
     32  eor #$60
     33  sta page
     34  ldx #$7F
     35  jsr draw
     36 
     37 * If not a //c, then wait for vbl
     38 
     39  lda $FBC0
     40  beq :is2c
     41  lda $C019
     42  bpl *-3
     43  lda $C019
     44  bmi *-3
     45 :is2c
     46 
     47 * Now display that page
     48 
     49  bit $C054
     50  lda page
     51  cmp #$20
     52  beq *+5
     53  bit $C055
     54 
     55 * Now erase old image from last page
     56 
     57  eor #$60
     58  sta :smc0+2
     59  sta :smc1+2
     60  ldx #$20
     61  lda #0
     62 :loop tay
     63 :smc0 sta $2000,y
     64 :smc1 sta $2080,y
     65  iny
     66  bpl :smc0
     67  inc :smc0+2
     68  inc :smc1+2
     69  dex
     70  bne :loop
     71 
     72  inc index
     73  jmp mainloop
     74 
     75 *-------------------------------------------------
     76 
     77 draw stx color
     78 
     79  ldy #12-1
     80 :drawloop lda drawlist,y
     81  sty ysave
     82 
     83  pha
     84  and #15
     85  jsr getpoint
     86 
     87  tax
     88  tya
     89  ldy #0
     90  jsr $f457 ;plot
     91 
     92  pla
     93  lsr
     94  lsr
     95  lsr
     96  lsr
     97  jsr getpoint
     98  ldx #0
     99  jsr $f53a ;lineto
    100 
    101  ldy ysave
    102  dey
    103  bpl :drawloop
    104 
    105  lda yoffset
    106  clc
    107  adc yadd
    108  bne :not0
    109 
    110  inc yadd ;make +1
    111  inc yadd
    112 
    113 :not0 cmp #191-48-botYoffset
    114  bcc :0
    115 
    116  dec yadd ;make -1
    117  dec yadd
    118 
    119 :0 sta yoffset
    120  rts
    121 
    122 *-------------------------------------------------
    123 *
    124 * given a = point number, return a = xcoor, y = ycoor
    125 *
    126 
    127 getpoint tay
    128 
    129 * Get index into tables
    130 
    131  asl ;*16
    132  asl
    133  asl
    134  asl
    135  adc index
    136  and #$3F
    137  tax
    138  tya
    139 
    140  and #4 ;bottom?
    141  cmp #4
    142 
    143 * Compute ycoor
    144 
    145  lda ydata,x
    146  bcc :not_bot
    147  adc #botYoffset-1
    148 
    149 :not_bot adc yoffset
    150  tay
    151 
    152 * Compute xcoor
    153 
    154  lda xdata,x
    155  adc #mainXoffset
    156  rts
    157 
    158 *-------------------------------------------------
    159 
    160 drawlist hex 01122330 ;draw top
    161  hex 45566774 ;draw bottom
    162  hex 04152637 ;draw connecting lines
    163 
    164 xdata hex 908F8E8C8A87837F7A757069635C564F
    165  hex 484039332C261F1A15100C0805030100
    166  hex 0000010305080C10151A1F262C333940
    167  hex 474F565C636970757A7F83878A8C8E8F
    168 
    169 ydata hex 181A1C1E21232527282A2B2D2E2E2F2F
    170  hex 2F2F2F2E2E2D2B2A28272523211E1C1A
    171  hex 181513110E0C0A080705040201010000
    172  hex 000000010102040507080A0C0E111315
    173 
    174 *-------------------------------------------------