Advertisement
Guest User

2018 ra sesion02 amstrad cpctelera example

a guest
Sep 17th, 2018
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;-----------------------------LICENSE NOTICE------------------------------------
  2. ;;  This file is part of CPCtelera: An Amstrad CPC Game Engine
  3. ;;  Copyright (C) 2018 ronaldo / Fremos / Cheesetea / ByteRealms (@FranGallegoBR)
  4. ;;
  5. ;;  This program is free software: you can redistribute it and/or modify
  6. ;;  it under the terms of the GNU Lesser General Public License as published by
  7. ;;  the Free Software Foundation, either version 3 of the License, or
  8. ;;  (at your option) any later version.
  9. ;;
  10. ;;  This program is distributed in the hope that it will be useful,
  11. ;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;;  GNU Lesser General Public License for more details.
  14. ;;
  15. ;;  You should have received a copy of the GNU Lesser General Public License
  16. ;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. ;;-------------------------------------------------------------------------------
  18.  
  19. ;; Include all CPCtelera constant definitions, macros and variables
  20. .include "cpctelera.h.s"
  21.  
  22. ;;
  23. ;; Start of _DATA area
  24. ;;  SDCC requires at least _DATA and _CODE areas to be declared, but you may use
  25. ;;  any one of them for any purpose. Usually, compiler puts _DATA area contents
  26. ;;  right after _CODE area contents.
  27. ;;
  28. .area _DATA
  29. .area _CODE
  30.  
  31. hero_data:
  32.    .db   0x14, 0x21     ;; X, Y
  33.    .db   0x02, 0x08     ;; W, H
  34.    .db   0x0F           ;; Color
  35.  
  36. enemy_data:
  37.    .db   0x20, 0x01     ;; X, Y
  38.    .db   0x02, 0x08     ;; W, H
  39.    .db   0xFF           ;; Color
  40.  
  41. ;;
  42. ;; Declare all function entry points as global symbols for the compiler.
  43. ;; (The linker will know what to do with them)
  44. ;; WARNING: Every global symbol declared will be linked, so DO NOT declare
  45. ;; symbols for functions you do not use.
  46. ;;
  47. .globl cpct_disableFirmware_asm
  48. .globl cpct_drawSolidBox_asm
  49. .globl cpct_getScreenPtr_asm
  50.  
  51. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  52. ;; DIBUJAR UNA ENTIDAD
  53. ;; REGISTROS DESTRUIDOS: AF, BC, DE, HL
  54. ;; ENTRADA: IX -> Puntero a entidad
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56. ent_draw:
  57.    ld    de, #0xC000       ;;Comienzo memoria de video
  58.    ld     c, 1(ix)         ;; C = Entity Y
  59.    ld     b, 0(ix)         ;; B = Entity X
  60.    call cpct_getScreenPtr_asm
  61.  
  62.    ex    de, hl   ;; DE = Puntero a memoria
  63.    ld  a, 4(ix)   ;; Color
  64.    ld  b, 3(ix)   ;; alto
  65.    ld  c, 2(ix)   ;; Ancho
  66.  
  67.    call cpct_drawSolidBox_asm
  68.  
  69.    ret
  70.  
  71. ;;
  72. ;; MAIN function. This is the entry point of the application.
  73. ;;    _main:: global symbol is required for correctly compiling and linking
  74. ;;
  75. _main::
  76.    ;; Disable firmware to prevent it from interfering with string drawing
  77.    call cpct_disableFirmware_asm
  78.  
  79.    ld    ix, #hero_data
  80.    call ent_draw
  81.  
  82.    ld    ix, #enemy_data
  83.    call ent_draw
  84.  
  85.    ;; Loop forever
  86. loop:
  87.    jr    loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement