Guest User

Untitled

a guest
Feb 6th, 2014
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. CurrentRoomMonsterGraphicsIndex = $207a
  4. ObjectPosScreen = $0460
  5.  
  6.  
  7. ;......................................................................................................
  8. PrepPalGDMA:
  9.       lda [$00]
  10.       sta Window
  11.      
  12.       asl a
  13.       asl a
  14.       clc
  15.       adc Window
  16.       inc a
  17.       asl Window
  18.       adc Window      ; Y= (num*6)+num+1. no overflow should occur
  19.       adc <$00
  20.       sta <$00
  21.       lda <$01
  22.       adc #$00
  23.       sta <$01
  24.      
  25.       ;asl Window
  26.       tya             ; setup pointer for WORD index
  27.       asl a
  28.       tay
  29.  
  30.       lda [$00],y     ; palette bank
  31.       sta GDMA.bank
  32.      
  33.       tya          
  34.       clc
  35.       adc Window
  36.       tay        
  37.  
  38.       lda [$00],y     ; source address
  39.       iny
  40.       sta GDMA+1
  41.       lda [$00],y
  42.       and #$1f
  43.       tst #$01, GDMA.bank
  44.       beq .lower
  45. .upper
  46.       ora #$A0
  47. .lower
  48.       ora #$80
  49.       sta GDMA+2
  50.  
  51.       dey
  52.       tya          
  53.       clc
  54.       adc Window
  55.       tay        
  56.  
  57.       lda [$00],y     ; cram address
  58.       asl a
  59.       asl a
  60.       asl a
  61.       asl a
  62.       sta GDMA.Vaddr
  63.  
  64.       lda #$20
  65.       sta GDMA+5
  66.       stz GDMA+6
  67.  
  68.       ;opcodes
  69.       lda #$e3
  70.       sta GDMA+0
  71.       lda #$60
  72.       sta GDMA+7
  73.  
  74.       ;destination
  75.       lda #$04
  76.       sta GDMA+3
  77.       lda #$64
  78.       sta GDMA+4
  79.  
  80.       dec GDMA.bank
  81.       dec GDMA.bank
  82.       lsr GDMA.bank
  83.  
  84.       lda #$02
  85.       sta GDMA.flag
  86.  
  87.            
  88.     rts
  89.  
  90. ;......................................................................................................
  91. PrepGDMA:
  92.       ;iny            ;prep index. move past first table
  93.       lda [$00]     ;read table without index. already primed for offset
  94.       sta Window    ;prep window offset
  95.      
  96.       ldy <$59      ;index from <$59
  97.                     ;normally this would be incremented, but it was incremented
  98.                     ;outside the call routine. Decrement further down to realign.
  99.      
  100.                     ;get bank #
  101.       lda [$00],y
  102.       sta GDMA.bank
  103.                    
  104.                     ;advance to next table
  105.       lda Window
  106.       inc a
  107.       clc
  108.       adc <$00
  109.       sta <$00
  110.       bcc .skip
  111.       inc <$01
  112. .skip
  113.       asl Window    ;prep Window for advancing WORD size tables
  114.      
  115.       tya           ;index from <$59. Convert to WORD indexing
  116.       dec a         ;<$59 is always +1. Fixed.
  117.       asl a
  118.       tay
  119.      
  120.                     ;get logical address
  121.       lda [$00],y
  122.       iny
  123.       sta GDMA+1
  124.       lda [$00],y
  125.       and #$1f
  126.       tst #$01, GDMA.bank
  127.       beq .lower
  128. .upper
  129.       ora #$A0
  130. .lower
  131.       ora #$80
  132.       sta GDMA+2
  133.  
  134.                     ;increment pointer to next table
  135.       dey
  136.       tya          
  137.       clc
  138.       adc Window
  139.       tay        
  140.        
  141.                     ;payload size
  142.       lda [$00],y
  143.       iny
  144.       sta GDMA+5
  145.       lda [$00],y
  146.       sta GDMA+6
  147.  
  148.                     ;increment pointer to next table
  149.       dey
  150.       tya          
  151.       clc
  152.       adc Window
  153.       tay        
  154.            
  155.                     ;vram address
  156.       lda [$00],y
  157.       iny
  158.       sta GDMA.Vaddr
  159.       lda [$00],y
  160.       sta GDMA.Vaddr+1
  161.      
  162.       ;opcodes
  163.       lda #$e3
  164.       sta GDMA+0
  165.       lda #$60
  166.       sta GDMA+7
  167.  
  168.       ;destination
  169.       lda #$02
  170.       sta GDMA+3
  171.       lda #$60
  172.       sta GDMA+4
  173.  
  174.       dec GDMA.bank
  175.       dec GDMA.bank
  176.       lsr GDMA.bank
  177.  
  178.       lda #$01
  179.       sta GDMA.flag
  180.  
  181.  
  182.     rts
  183.  
  184.  
  185.  
  186. ;#######################################################################################################
  187.  
  188. GetRoomGraphics:
  189.       lda <$00
  190.       pha
  191.       lda <$01
  192.       pha
  193.  
  194.  
  195.       lda CurrentStage
  196.       asl a
  197.       tax
  198.       lda .table,x
  199.       sta <$00
  200.       lda .table+1,x
  201.       sta <$01
  202.  
  203.  
  204.       cly
  205. .loop
  206.       lda [$00],y
  207.       cmp Window
  208.       beq .match
  209.       cmp #$ff
  210.       beq .error
  211.       iny
  212.       bra .loop
  213. .error
  214.       ;!?
  215.       pla
  216.       sta <$01
  217.       pla
  218.       sta <$00
  219.     rts
  220.    
  221. .match
  222.       sty Window  ;store the room index
  223.      
  224.                   ;advance the pointer
  225. .loop2
  226.       lda [$00],y
  227.       iny
  228.       cmp #$ff
  229.       bne .loop2
  230.      
  231.                   ;get room table offset
  232.       ;sta Window ;<- reusing var name, but isn't 'Window'. Temp for holding index value.
  233.       ;tya
  234.       ;asl a
  235.       ;tay
  236.      
  237.       tya
  238.       asl Window
  239.       clc
  240.       adc Window
  241.       tay
  242.       ;lsr Window
  243.      
  244.       lda [$00],y
  245.       iny
  246.       tax
  247.       lda [$00],y
  248.       sta <$01
  249.       stx <$00    ;<- now pointing to .Room%Num
  250.      
  251.       lda <$59
  252.       dec a
  253.       cmp [$00]
  254.       bcs .DoPalette
  255.       ;cly
  256.       jsr PrepGDMA
  257.       bra .exit
  258.  
  259. .DoPalette
  260.       sec
  261.       sbc [$00]
  262.       tay
  263.       cmp [$00]
  264.       bcs .done
  265.       jsr PrepPalGDMA
  266.       bra .exit    
  267. .done    
  268.       lda #$28
  269.       sta <$59
  270. .exit
  271.       pla
  272.       sta <$01
  273.       pla
  274.       sta <$00
  275.     rts
  276.      
  277.      
  278.      
  279.  
  280. .table .dw _Cutman, _Iceman, _Bombman, _Fireman, _Elecman, _Gutsman
  281.  
  282. _Cutman
  283.  
  284. .table      
  285.         .db $00,$21,$2c,$37,$ff
  286. .RoomGrafx
  287.         .dw .Room0Table, .Room1Table, .Room2Table, .Room3Table
  288.        
  289.    
  290. ;.................................................................................................      
  291. .Room0Table    
  292.      
  293. .Room0Num
  294.       .db 6
  295. .Room0Bank      
  296.       .db bank(Octopus_spr),bank(Blader_spr),bank(Flea_spr),bank(Cutter_spr),bank(Beak_spr)
  297.       .db bank(FlyShell_spr)
  298. .Room0Addr
  299.       .dw Octopus_spr,Blader_spr,Flea_spr,Cutter_spr,Beak_spr
  300.       .dw FlyShell_spr
  301. .Room0Sizeof
  302.       .dw sizeof(Octopus_spr),sizeof(Blader_spr),sizeof(Flea_spr),sizeof(Cutter_spr),sizeof(Beak_spr)
  303.       .dw sizeof(FlyShell_spr)
  304. .Room0Vaddr
  305.       .dw ($00 * $40)+$3000,($0a * $40)+$3000,($15 * $40)+$3000,($25 * $40)+$3000,($30 * $40)+$3000
  306.       .dw ($40 * $40)+$3000
  307. .Room0PBank
  308.       .dw bank(Octopus_pal),bank(Blader_pal),bank(Flea_pal),bank(Cutter_pal),bank(Beak_pal)
  309.       .dw bank(FlyShell_pal)
  310. .Room0Paddr
  311.       .dw Octopus_pal,Blader_pal,Flea_pal,Cutter_pal,Beak_pal
  312.       .dw FlyShell_pal
  313. .Room0Pslot
  314.       .dw 0+4, 1+4, 2+4, 4+4, 6+4, 8+4      
  315.  
  316.  
  317. ;.................................................................................................      
  318. .Room1Table    
  319.      
  320. .Room1Num
  321.       .db 6
  322. .Room1Bank      
  323.       .db bank(Octopus_spr),bank(Blader_spr),bank(Flea_spr),bank(Cutter_spr),bank(Beak_spr)
  324.       .db bank(FlyShell_spr)
  325. .Room1Addr
  326.       .dw Octopus_spr,Blader_spr,Flea_spr,Cutter_spr,Beak_spr
  327.       .dw FlyShell_spr
  328. .Room1Sizeof
  329.       .dw sizeof(Octopus_spr),sizeof(Blader_spr),sizeof(Flea_spr),sizeof(Cutter_spr),sizeof(Beak_spr)
  330.       .dw sizeof(FlyShell_spr)
  331. .Room1Vaddr
  332.       .dw ($00 * $40)+$3000,($0a * $40)+$3000,($15 * $40)+$3000,($25 * $40)+$3000,($31 * $40)+$3000
  333.       .dw ($40 * $40)+$3000
  334. .Room1PBank
  335.       .dw bank(Octopus_pal),bank(Blader_pal),bank(Flea_pal),bank(Cutter_pal),bank(Beak_pal)
  336.       .dw bank(FlyShell_pal)
  337. .Room1Paddr
  338.       .dw Octopus_pal,Blader_pal,Flea_pal,Cutter_pal,Beak_pal
  339.       .dw FlyShell_pal
  340. .Room1Pslot
  341.       .dw 0+4, 1+4, 2+4, 4+4, 6+4, 8+4      
  342.  
  343. ;.................................................................................................      
  344. .Room2Table
  345.      
  346. .Room2Num
  347.       .db 6
  348. .Room2Bank      
  349.       .db bank(Octopus_spr),bank(Blader_spr),bank(BigEye_spr),bank(Cutter_spr),bank(Beak_spr)
  350.       .db bank(FlyShell_spr)
  351. .Room2Addr
  352.       .dw Octopus_spr,Blader_spr,BigEye_spr,Cutter_spr,Beak_spr
  353.       .dw FlyShell_spr
  354. .Room2Sizeof
  355.       .dw sizeof(Octopus_spr),sizeof(Blader_spr),sizeof(BigEye_spr),sizeof(Cutter_spr),sizeof(Beak_spr)
  356.       .dw sizeof(FlyShell_spr)
  357. .Room2Vaddr
  358.       .dw ($00 * $40)+$3000,($0a * $40)+$3000,($10 * $40)+$3000,($25 * $40)+$3000,($31 * $40)+$3000
  359.       .dw ($40 * $40)+$3000
  360. .Room2PBank
  361.       .dw bank(Octopus_pal),bank(Blader_pal),bank(BigEye_spr),bank(Cutter_pal),bank(Beak_pal)
  362.       .dw bank(FlyShell_pal)
  363. .Room2Paddr
  364.       .dw Octopus_pal,Blader_pal,BigEye_pal,Cutter_pal,Beak_pal
  365.       .dw FlyShell_pal
  366. .Room2Pslot
  367.       .dw 0+4, 1+4, 2+4, 4+4, 6+4, 8+4      
  368.  
  369. ;.................................................................................................      
  370. .Room3Table    
  371.      
  372. .Room3Num
  373.       .db 6
  374. .Room3Bank      
  375.       .db bank(Octopus_spr),bank(Blader_spr),bank(Flea_spr),bank(Cutter_spr),bank(ScrewBomber_spr)
  376.       .db bank(FlyShell_spr)
  377. .Room3Addr
  378.       .dw Octopus_spr,Blader_spr,Flea_spr,Cutter_spr,ScrewBomber_spr
  379.       .dw FlyShell_spr
  380. .Room3Sizeof
  381.       .dw sizeof(Octopus_spr),sizeof(Blader_spr),sizeof(Flea_spr),sizeof(Cutter_spr),sizeof(ScrewBomber_spr)
  382.       .dw sizeof(FlyShell_spr)
  383. .Room3Vaddr
  384.       .dw ($00 * $40)+$3000,($0a * $40)+$3000,($15 * $40)+$3000,($25 * $40)+$3000,($35 * $40)+$3000
  385.       .dw ($40 * $40)+$3000
  386. .Room3PBank
  387.       .dw bank(Octopus_pal),bank(Blader_pal),bank(BigEye_spr),bank(Cutter_pal),bank(ScrewBomber_pal)
  388.       .dw bank(FlyShell_pal)
  389. .Room3Paddr
  390.       .dw Octopus_pal,Blader_pal,BigEye_pal,Cutter_pal,ScrewBomber_pal
  391.       .dw FlyShell_pal
  392. .Room3Pslot
  393.       .dw 0+4, 1+4, 2+4, 4+4, 6+4, 8+4      
  394.  
  395.  
  396. _Iceman
  397.  
  398. _Bombman
  399.  
  400. _Fireman
  401.  
  402. _Elecman
  403.  
  404. _Gutsman
RAW Paste Data