Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;-----------------------------LICENSE NOTICE------------------------------------
- ;; This file is part of CPCtelera: An Amstrad CPC Game Engine
- ;; Copyright (C) 2018 ronaldo / Fremos / Cheesetea / ByteRealms (@FranGallegoBR)
- ;;
- ;; This program is free software: you can redistribute it and/or modify
- ;; it under the terms of the GNU Lesser General Public License as published by
- ;; the Free Software Foundation, either version 3 of the License, or
- ;; (at your option) any later version.
- ;;
- ;; This program is distributed in the hope that it will be useful,
- ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ;; GNU Lesser General Public License for more details.
- ;;
- ;; You should have received a copy of the GNU Lesser General Public License
- ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
- ;;-------------------------------------------------------------------------------
- ;; Include all CPCtelera constant definitions, macros and variables
- .include "cpctelera.h.s"
- ;;
- ;; Start of _DATA area
- ;; SDCC requires at least _DATA and _CODE areas to be declared, but you may use
- ;; any one of them for any purpose. Usually, compiler puts _DATA area contents
- ;; right after _CODE area contents.
- ;;
- .area _DATA
- .area _CODE
- .macro DefineEntity _name, _x, _y, _vx, _vy, _w, _h, _col, _upd
- _name:
- .db _x, _y ;; X, Y
- .db _vx, _vy ;; VX, VY
- .db _w, _h ;; W, H
- .db _col ;; Color
- .dw _upd ;; Update
- .endm
- e_x = 0
- e_y = 1
- e_vx = 2
- e_vy = 3
- e_w = 4
- e_h = 5
- e_col = 6
- e_up_l = 7
- e_up_h = 8
- DefineEntity hero_data, 0x14, 0x21, 0x01, 0x01, 0x02, 0x08, 0x0F, ent_moveKeyboard
- DefineEntity enemy_data, 0x20, 0x01, 0xFF, 0x00, 0x02, 0x08, 0xFF, ent_move
- ;;
- ;; Declare all function entry points as global symbols for the compiler.
- ;; (The linker will know what to do with them)
- ;; WARNING: Every global symbol declared will be linked, so DO NOT declare
- ;; symbols for functions you do not use.
- ;;
- .globl cpct_disableFirmware_asm
- .globl cpct_drawSolidBox_asm
- .globl cpct_getScreenPtr_asm
- .globl cpct_waitVSYNC_asm
- .globl cpct_setVideoMode_asm
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; DIBUJAR UNA ENTIDAD
- ;; REGISTROS DESTRUIDOS: AF, BC, DE, HL
- ;; ENTRADA: IX -> Puntero a entidad
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ent_draw:
- ld de, #0xC000 ;;Comienzo memoria de video
- ld c, e_x(ix) ;; C = Entity Y
- ld b, e_y(ix) ;; B = Entity X
- call cpct_getScreenPtr_asm
- ex de, hl ;; DE = Puntero a memoria
- ld a, e_col(ix) ;; Color
- ld b, e_h(ix) ;; alto
- ld c, e_w(ix) ;; Ancho
- call cpct_drawSolidBox_asm
- ret
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; BORRA UNA ENTIDAD
- ;; REGISTROS DESTRUIDOS: AF, BC, DE, HL
- ;; ENTRADA: IX -> Puntero a entidad
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ent_clear:
- ld a, e_col(ix)
- ex af, af'
- ld e_col(ix), #0
- call ent_draw
- ex af, af'
- ld e_col(ix), a
- ret
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; ACTUALIZAR UNA ENTIDAD
- ;; REGISTROS DESTRUIDOS:
- ;; ENTRADA: IX -> Puntero a entidad
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ent_update:
- ld h, e_up_h(ix)
- ld l, e_up_l(ix)
- jp (hl)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; MOVER UNA ENTIDAD CON TECLADO
- ;; REGISTROS DESTRUIDOS:
- ;; ENTRADA: IX -> Puntero a entidad
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ent_moveKeyboard:
- ret
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; MOVER UNA ENTIDAD
- ;; REGISTROS DESTRUIDOS:
- ;; ENTRADA: IX -> Puntero a entidad
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ent_move:
- ld a, e_x(ix)
- add e_vx(ix)
- ld e_x(ix), a
- ld a, e_y(ix)
- add e_vy(ix)
- ld e_y(ix), a
- ret
- ;;
- ;; MAIN function. This is the entry point of the application.
- ;; _main:: global symbol is required for correctly compiling and linking
- ;;
- _main::
- ;; Disable firmware to prevent it from interfering with string drawing
- call cpct_disableFirmware_asm
- ld c, #0
- call cpct_setVideoMode_asm
- loop:
- ld ix, #hero_data
- call ent_clear
- call ent_update
- call ent_draw
- ld ix, #enemy_data
- call ent_clear
- call ent_update
- call ent_draw
- call cpct_waitVSYNC_asm
- ;; Loop forever
- jr loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement