#include "ti83plus.inc" #include "ion.inc" .org progstart-2 .db t2ByteTok, tasmCmp ;###############_CONSTANTS_############## #DEFINE MAP_WIDTH 11 ;width of the map #DEFINE MAP_HEIGHT 11 ; #DEFINE COLUMNS_TO_DRAW (6+1) ;columns to draw #DEFINE HRZ_SCROLL 2 ;with 2 tiles between the player and the edge, scroll map #DEFINE VERT_SCROLL 1 ;###############_PLAYER_############### #DEFINE P_MONEY 0 #DEFINE P_X 2 #DEFINE P_Y 3 #DEFINE P_DIR 4 #DEFINE P_CHAR 5 #DEFINE P_SIZE 6 ;##############_TEXT_################ #DEFINE T_EOS $FF #DEFINE T_SPACE $FE #DEFINE T_NEWLINE $FD #DEFINE T_INSERT $FC #DEFINE I_MONEY 1 #DEFINE I_PLAYER 2 #DEFINE I_PROPERTY 3 #DEFINE I_OWNEDBY 4 #DEFINE T_MENU $FB #DEFINE T_CHANCE_MOVE $FA ;###############_VARIABLES_################ chanceDeck = saferam4 ;0-16 SR4 HAS 66 BYTES commChestDeck = chanceDeck+17 ;17-32 curOption = commChestDeck+17 ;33 for the menu routine, the highlighted option buttonCoords = curOption+1 ;34: coordinates for menu buttons players = gbuf ;money - 2, X, Y, Direction, Character initialize: di ld hl,$89EC ;byte after saferam1 (savesscreen) (creando nuestro "saferam") ld de,saferam3 ;guardar los valores aqui para no estropear todo ld bc,78 ldir ;guardarlo ld hl,chanceDeck+16 call setUpCards ;create/shuffle chance cards ld hl,commChestDeck+16 call setUpCards ;create/shuffle comm chest cards ld a,2 ld (numberPlayers),a ld hl,players ld b,2 initPlayers: push bc ld de,1500 ld (hl),e ;money inc hl ld (hl),d inc hl ld (hl),10 ;playerX inc hl ld (hl),10 ;playerY inc hl ld (hl),0 ;direction inc hl ld b,256/4 call randomNumber ld (hl),c ;character's sprite# inc hl pop bc djnz initPlayers ld hl,currentPlayer ld (hl),0 call loadPlayer ;main program loop start: call drawMap ;draw map and players call drawMenu jp drawGbuf #include "monoKeyLoop.asm" jr start ;############################# ;#DRAWMENU ;#Display the main game menu ;#Assume everything destroyed. ;############################# drawMenu: call drawTextTop ld hl,textMenu call drawText call drawTextBottom push af call drawMap ;"erase" the screen ;) pop af ld hl,start push hl ;go to start after running the routines or a jp z,movePlayer ;if first option (option 0), roll dice dec a jp z,statsMenu ;2nd option: draw stats menu pop hl ;####VERY IMPORTANT! WE NEED TO RESTORE THESE VALUES BEFORE QUITTING#### quit: ld hl,saferam3 ;guardar los valores aqu? para no joderlo todo ld de,$89EC ;byte after saferam1 (savesscreen) ld bc,78 ldir ;save it all ret statsMenu: call drawTextTop ld hl,textMoney call drawText call drawTextBottom ret textMoney ;Player [X] ;Money: $[playermoney] ;[]View properties ;[]Buy houses ;[]Return .db _P,_l,_a,_y,_e,_r,T_SPACE,T_INSERT,I_PLAYER,T_NEWLINE .db _M,_o,_n,_e,_y,_COLON,T_SPACE,_DOLLAR,T_INSERT,I_MONEY,T_NEWLINE .db T_MENU,_V,_i,_e,_w,T_SPACE,_o,_w,_n,_e,_d,T_NEWLINE .db T_MENU,_B,_u,_y,T_SPACE,_h,_o,_u,_s,_e,_s,T_NEWLINE .db T_MENU,_R,_e,_t,_u,_r,_n,T_EOS ;######################## ;#MAP MOVEMENT ROUTINES ;# displace the map ;######################## mapRight: ld hl,xCoord ld a,MAP_WIDTH-6 cp (hl) ret z ld de,xOff ld a,(de) inc a inc a and $0F ld (de),a jp nz,updateRotation ;if we have no overflow, we're all good. inc (hl) jp updateRotation mapLeft: ld hl,xCoord xor a cp (hl) ld de,xOff ld a,(de) jr nz,mL_notLeft or a ret z mL_notLeft: dec a dec a and $0F ld (de),a cp 14 jp c,updateRotation ;if we have no overflow, we're all good. dec (hl) ld hl,mPL_adjustCP inc (hl) jp updateRotation mapUp: ld hl,yCoord xor a cp (hl) ld de,yOff ld a,(de) jr nz,mU_notTop or a ret z mU_notTop: dec a dec a and $0F ld (de),a cp 14 ret c ;if we have no overflow, we're all good. dec (hl) ld hl,mPU_adjustCP inc (hl) ret mapDown: ld hl,yCoord ld a,MAP_HEIGHT-4 cp (hl) ret z ld de,yOff ld a,(de) inc a inc a and $0F ld (de),a ret nz ;if we have no overflow, we're all good. inc (hl) ret ;########################## ;#UPDATEROTATION ;#After changing the x offset ;# of the map, we need to update ;# the rotation in the fastcopy ;# routine. ;#Explanation: ;#It's a bit confusing i admit, ;# if you have any questions about ;# this part it'd probably be better ;# for now just to ask me personally ;# about it. ;########################## updateRotation: ld a,(xOff) ;what is the xOffset? and 7 ;we're only interested in the lower three bits (essentially xOff % 8) ld hl,gbufMask ld e,a ld d,0 add hl,de ;pointer to the rotation mask ex af,af' ;save a (swap with shadow register) ld a,(hl) ld hl,maskLeft ld (hl),a ld hl,maskRight cpl ;xor $FF ld (hl),a ex af,af' ld hl,rotateRight cp 4 jr nc,rotarDer ld hl,rotateLeft rotarDer: and %00000011 ld e,a ld d,0 add hl,de push hl ld de,rotLeft ldi ldi ldi ldi pop hl ld de,rotRight ldi ldi ldi ldi ret rotateRight: ;if offset greater than or equal to 4, rotate the gbuf right up to four times rrca rrca rrca rrca rotateLeft: ;the nops keep it smoother (same delay as rlca) nop ; so whether we shift or not, it will take the same amount of cycles nop nop nop rlca rlca rlca rlca gbufMask: .db %11111111 ;0 display all of the first byte, none of the second .db %11111110 ;1 after rotating left once, we only want the 7 leftern most bits of byte 1, and rightmost bit of byte 2 .db %11111100 ;2 .db %11111000 ;3 .db %11110000 ;4 .db %11100000 ;5 .db %11000000 ;6 .db %10000000 ;7 drawGbuf: ld a,$80 out ($10),a ;set row ($80: 0, to $BF:63) ld hl,saferam1-14+(14*64)-14 ; ; xOff = $+1 ld a,0 ;if xOff > 8, skip the first byte (it's offscreen) cp 8 jr c,$+3 inc hl noSkip: yOff = $+1 ld b,0 inc b ld de,14 add hl,de djnz $-4 noSkip2: ld a,$20 ;$20: col 0, $2E: col 14 ld c,a ld b,64 ;64 filas fastCopyAgain: inc c ;avanzar a proxima fila push bc ld de,-(14*64) out ($10),a ;actualizar columna add hl,de ld de,13 inc hl fastCopyLoop: add hl,de ld a,(hl) ;cargar valor en gbuf a a rotLeft: .db 0,0,0,0 ;rotate the values we need maskLeft = $+1 and $FF ;necesitamos los valores de la izquierda ld c,a inc hl ld a,(hl) ;el proximo byte que llena el resto del primero rotRight: .db 0,0,0,0 maskRight = $+1 and 0 or c out ($11),a djnz fastCopyLoop pop bc ld a,c cp $2B+1 jr nz,fastCopyAgain ret #include "monoMap.asm" #include "monoSpriteRoutines.asm" #include "monoMove.asm" #include "monoText.asm" #include "monoChance.asm" #include "monoPlayer.asm" ;######_DATA_###### #include "monopoly_map.asm" #include "monopoly_map_tiles.asm" #include "monopoly_sprites.asm" #include "monopoly_alphabet.inc" textNeedMoney: ;You don't have enough money. .db _Y,_o,_u,T_SPACE,_d,_o,_n,_APOSTROPHE,_t,T_SPACE,_h,_a,_v,_e,T_SPACE,_e,_n,_o,_u,_g,_h,T_SPACE,_m,_o,_n,_e,_y,_PERIOD,T_EOS textBuy: ;[]Don't buy []Buy .db T_MENU,_D,_o,_n,_APOSTROPHE,_t,T_SPACE,_b,_u,_y,T_SPACE,T_MENU,_B,_u,_y,T_EOS textLandedOn: ;You've landed on: ;[property] .db _Y,_o,_u,_APOSTROPHE,_v,_e,T_SPACE,_l,_a,_n,_d,_e,_d,T_SPACE,_o,_n,_COLON,T_NEWLINE .db T_INSERT,I_PROPERTY,T_NEWLINE,T_EOS textNextPlayer: ;Next player .db _N,_e,_x,_t,T_SPACE,_p,_l,_a,_y,_e,_r,T_EOS textPropertyOwned: ;This property is owned. Pay player [] $[] .db _T,_h,_i,_s,T_SPACE,_p,_r,_o,_p,_e,_r,_t,_y,T_SPACE,_i,_s,T_SPACE,_o,_w,_n,_e,_d,_PERIOD,T_SPACE,T_NEWLINE .db _P,_a,_y,T_SPACE,_p,_l,_a,_y,_e,_r,T_SPACE,T_INSERT,I_OWNEDBY,_COLON,T_SPACE,_DOLLAR,T_EOS textPropertyPrice: ;This property is unowned. ;It costs $ .db _T,_h,_i,_s,T_SPACE,_p,_r,_o,_p,_e,_r,_t,_y,T_SPACE,_i,_s,T_SPACE,_u,_n,_o,_w,_n,_e,_d,_PERIOD,T_NEWLINE .db _I,_t,T_SPACE,_c,_o,_s,_t,_s,T_SPACE,_DOLLAR,T_EOS textYouHave: ;You have: $ .db _Y,_o,_u,T_SPACE,_h,_a,_v,_e,_COLON,T_SPACE,_DOLLAR,T_EOS textGO: ;You have passed GO, please collect $200. .db _Y,_o,_u,T_SPACE,_h,_a,_v,_e,T_SPACE,_p,_a,_s,_s,_e,_d,T_SPACE,_G,_O,_COMMA,T_SPACE,_p,_l,_e,_a,_s,_e,T_SPACE,_c,_o,_l,_l,_e,_c,_t,T_SPACE,_DOLLAR,_2,_O,_O,_PERIOD,T_EOS textMenu: ;Player [X] ;[Roll dice ;[View stats ;[Exit .db _P,_l,_a,_y,_e,_r,T_SPACE,T_INSERT,I_PLAYER,T_NEWLINE .db T_MENU,_R,_o,_l,_l,T_SPACE,_d,_i,_c,_e,T_NEWLINE .db T_MENU,_V,_i,_e,_w,T_SPACE,_s,_t,_a,_t,_s,T_NEWLINE .db T_MENU,_E,_x,_i,_t,T_EOS