**************************************************************************** **************************************************************************** ** ** Platinum (Shop routines) ** ** This software is in the public domain. There is no warranty. ** ** by Patrick Davidson (pad@calc.org, http://pad.calc.org/) ** ** Last updated July 28, 2001 ** **************************************************************************** **************************************************************************** L_SHIELD set 99 LINE_HEIGHT set 6 ITEM_FONT set 0 ITEMS_Y set 10 PRICE_X set 120 ******************************************** PURCHASE ITEMS Platinum_Shop: cmp.l #$50,cash(a5) bmi Status_Prepare bsr Read_Key_Edges bsr Draw_Shop moveq #0,D5 ; D5 = item selected Platinum_Shop_Loop: bsr Timer_Delay bsr Display_Game_Screen cmp.l #$50,cash(a5) bmi Status_Prepare moveq #86,d1 lea 6+32*8(a5),a0 PSL_CLC: ; Clear left side (arrow area) clr.b (a0) lea 32(a0),a0 dbra d1,PSL_CLC move.w d5,d4 mulu #32*LINE_HEIGHT,d4 lea 6(a5),a0 add.w #32*ITEMS_Y,a0 add.w d4,a0 lea arrow(pc),a1 moveq #7,d0 loop_draw_arrow: move.b (a1)+,(a0) lea 32(a0),a0 dbra d0,loop_draw_arrow bsr Read_Key_Edges GETKEY 6,0,8,6 ; Test ESC key beq Status_Prepare GETKEY 0,0,0,5 ; Test up arrow beq.s shop_go_up GETKEY 0,2,0,7 ; Test down arrow beq.s shop_go_down GETKEY 1,0,9,1 bne Platinum_Shop_Loop move.w d5,d4 add.w d4,d4 add.w d4,d4 ; D4 = offset of table entry move.w Shop_Items(pc,d4.w),d0 lea Shop_Items(pc,d0.w),a0 move.l cash(a5),d6 ; D0 = current cash cmp.l (a0)+,d6 ; D0 = cash left bmi Platinum_Shop_Loop ; Cancel purchase if < 0 jsr (a0) ; Call activation routine bne Platinum_Shop_Loop lea cash+4(a5),a1 bsr Sub_BCD bra Platinum_Shop_Loop shop_go_up: tst.w d5 beq Platinum_Shop_Loop subq.w #1,d5 bra Platinum_Shop_Loop shop_go_down: cmp.w #num_i-1,d5 beq Platinum_Shop_Loop addq.w #1,d5 bra Platinum_Shop_Loop ******************************************** SHOP ITEMS LIST * * This macro is used to create a table of shop items. Each item must have * labels psd_ for the data and code controlling it, and psd_ for * the description defined. The description is simply a string which will * be displayed in the list of items. * * The data/code first has one word which is the price of the item. If the * player tries to buy it (and has enough money) then the code beginning * immediately after it will be called. The code should then do whatever is * needed to handle the player's purchase. It should return with the zero * flag set if the player should be charged, and clear when the player should * not be charged (that is, if the user already has the item, or the maximum * amount possible of something that you can buy multiple instances of). * * The amount of money that the player will have after purchasing the item * is kept in D6, so D6 should not be changed unless you want to change this. * ******** num_i set 0 ITEM MACRO dc.w psd_\1-Shop_Items dc.w psn_\1-Shop_Items num_i set num_i+1 ENDM Shop_Items: ITEM Exit_Shop ITEM Shield_Boost ITEM Extra_Bullet ITEM Double_Shoot ITEM Triple_Shoot ITEM Quadruple_Shoot ITEM Rapid_Fire ITEM Dual_Plasma_Cannon ITEM Golden_Arches ITEM Triple_Plasma_Cannon ITEM Ultimate_Weapon ITEM Weapon_9 ******************************************** SHOP ITEMS DATA AND CODE psd_Shield_Boost: dc.l $50 move.w player_dmg(a5),d0 cmp.w #$50,d0 beq.s return_no_charge moveq #1,d0 move.b player_dmg+1(a5),d1 abcd d0,d1 move.b d1,player_dmg+1(a5) return_charge: ; Set flags to equal (charge) moveq #0,d0 rts return_no_charge: ; Set flags to != (no charge) moveq #1,d0 rts psd_Extra_Bullet: dc.l $100 move.w num_b(a5),d0 cmp.w #23,d0 beq.s return_no_charge addq.w #1,num_b(a5) bra.s return_charge psd_Rapid_Fire: dc.l $1000 cmp.w #-3,fire_delay(a5) beq.s return_no_charge move.w #-3,fire_delay(a5) bra.s return_charge psd_Golden_Arches: dc.l $2000 bset #4,weapons_available(a5) rts psd_Double_Shoot: dc.l $250 bset #0,weapons_available(a5) rts psd_Triple_Shoot: dc.l $400 bset #1,weapons_available(a5) rts psd_Quadruple_Shoot: dc.l $500 bset #2,weapons_available(a5) rts psd_Dual_Plasma_Cannon: dc.l $1500 bset #3,weapons_available(a5) rts psd_Triple_Plasma_Cannon: dc.l $2500 bset #5,weapons_available(a5) rts psd_Ultimate_Weapon: dc.l $3000 bset #6,weapons_available(a5) rts psd_Weapon_9: dc.l $4000 bset #7,weapons_available(a5) rts ******************************************** EXIT THE SHOP psd_Exit_Shop: dc.l 0 addq.l #4,sp bra Status_Prepare ******************************************** SHOP MESSAGES _shop_info: dc.b 'Welcome to the Platinum Edition Shop',0 psn_Exit_Shop: dc.b 'Exit the shop!',0 psn_Shield_Boost: dc.b '1-point shield recharge',0 psn_Extra_Bullet: dc.b 'Extra bullet',0 psn_Double_Shoot: dc.b 'Double Cannon (2)',0 psn_Triple_Shoot: dc.b 'Triple Cannon (3)',0 psn_Quadruple_Shoot: dc.b 'Quadruple Cannon (4)',0 psn_Rapid_Fire: dc.b 'Rapid-Fire Unit',0 psn_Dual_Plasma_Cannon: dc.b 'Dual Plasma Cannon (5)',0 psn_Golden_Arches: dc.b 'Golden Arches (6)',0 psn_Triple_Plasma_Cannon dc.b 'Triple Plasma Cannon (7)',0 psn_Ultimate_Weapon: dc.b 'Deluxe Plasma Cannon (8)',0 psn_Weapon_9: dc.b 'Ultimate Weapon (9)',0 price_template: dc.b '%x',0 EVEN ********************************************* arrow: dc.b %00011000 dc.b %00001100 dc.b %00000110 dc.b %11111111 dc.b %11111111 dc.b %00000110 dc.b %00001100 dc.b %00011000 ******************************************** DRAW THE SHOP Draw_Shop: bsr Clear_Screen moveq #ITEM_FONT,d0 bsr Set_Font moveq #num_i-1,d7 ; number of items remaining moveq #ITEMS_Y+2,d6 ; Y-coordinate lea Shop_Items(pc),a4 ; A4 -> item table lea (a4),a3 ; A3 -> item table PSI_ITEMS: moveq #12,d1 ; X-coordinate for description move.l d6,d0 ; Y-coordinate for this line move.l (a4)+,d4 ; Load data about this item ; and advance A4 to point to ; next item. lea 0(a3,d4.w),a0 ; Get ptr to info string in A0 bsr Display_String ; Display item info swap d4 ; Get price offset in D4 move.w 2(a3,d4.w),-(sp) ; Push price on stack pea price_template(pc) ; Push template of price pea _string_buffer(a5) ; Push string buffer jsr ____sprintf ; sprintf(buffer, template, price) lea 10(sp),sp moveq #120,d1 ; X-coordinate for price move.l d6,d0 ; Y-coordinate for this line lea _string_buffer(a5),a0 ; text of price bsr Display_String ; display price addq.l #LINE_HEIGHT,d6 ; Calc next Y-coordinate dbra d7,PSI_ITEMS ; Next item or finish moveq #0,d0 ; Set font to small bsr Set_Font lea _string_buffer(a5),a4 ; A4 -> string buffer move.w cash(a5),-(sp) ; Push amount of cash pea _shop_info(pc) ; Push format string pea (a4) ; Push buffer address jsr ____sprintf ; Write string into buffer lea (a4),a0 moveq #1,d0 moveq #0,d1 bsr Display_String ; Print Title message lea 10(sp),sp move.l plane1(a5),a0 lea 6(a5),a1 moveq #94,d0 loop_scopy: moveq #4,d2 loop_scopy2: move.l (a0)+,d1 move.l d1,3200(a1) move.l d1,(a1)+ dbra d2,loop_scopy2 lea 12(a1),a1 lea 10(a0),a0 dbra d0,loop_scopy rts