Advertisement
Eeems

Magic Menu routine

Apr 10th, 2011
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;displays the magic menu
  2. battle_magic:
  3.     call tobackbuff
  4.     rectangle(5,4,75,61,0) \ rectangle(4,5,76,60,0)
  5.     largeSprite(4,4,9,57,MenuImg)
  6.     ld hl,(6*256)+6
  7.     ld (penCol),hl
  8.     wrappedtext(MagicMenuTitle)
  9.     ld hl,(17*256)+16
  10.     ld (penCol),hl
  11.     ld a,16
  12.     ld (_cursor),a
  13.     ld hl,Magic_strings
  14.     ld de,BlackMageStats+black  ;thanks Runner112 no idea what some of this does
  15. _       ld a,(de)
  16.         or a
  17.             jr z,+_
  18.         push de
  19.             call DrawWrappedString
  20.         pop de
  21.         call mNewline   ;my addition
  22.         jr ++_
  23. _       ld c,a
  24.         cpir
  25. _       inc de
  26.         ld a,e
  27.         cp BlackMageStats+blue+1 & $FF
  28.             jr nz,---_
  29.     xor a   ;need cursor to be 0
  30.     ld (_cursor),a
  31. battle_magic_loop:
  32.     call battle_magic_menupick  ;draw pointer
  33.     lcdupdate
  34.     call battle_magic_menupick  ;erase pointer
  35. _   b_call _getCSC
  36.     cp skAlpha
  37.         jr z,_
  38.     cp skUp
  39.         jr z,battle_magic_up
  40.     cp skDown
  41.         jr z,battle_magic_down
  42.     cp skClear
  43.         jr nz,-_
  44. _   call frombackbuff
  45.     jp battle_return
  46. mNewline:
  47.     push af
  48.         ld a,(penRow)
  49.         add a,6
  50.         cp 55
  51.             call c,_
  52.             call nc,++_
  53.     pop af
  54.     ret
  55. _   call Newline
  56.     ld a,(_cursor)
  57.     ld (penCol),a
  58.     ret
  59. _   ld a,58
  60.     ld (_cursor),a
  61.     ld (penCol),a
  62.     ld a,17
  63.     ld (penRow),a
  64.     ret
  65. battle_magic_up:
  66.     ld a,(_cursor)
  67.     or a
  68.         jr z, battle_magic_loop
  69.     dec a
  70.     ld (_cursor),a
  71.     jr battle_magic_loop
  72. battle_magic_down:
  73.     ld a,(_cursor)
  74.     cp 9
  75.         jr z, battle_magic_loop
  76.     inc a
  77.     ld (_cursor),a
  78.     jr battle_magic_loop
  79. battle_magic_menupick:              ;need to draw the picker
  80.     push bc                         ;don't want to effect
  81.         push af                     ;all the registers
  82.             push hl                 ;so lets push them onto the stack
  83.                 call _              ;set x and y using call so it's easier to figure out in my head what does what. I should change that later
  84.                 ld b,8              ;and height
  85.                 ld ix,menupicker    ;and give it the right sprite
  86.                 call IPutSprite     ;draw it now!
  87.             pop hl                  ;and now we restore
  88.         pop af                      ;all the registers
  89.     pop bc                          ;back to normal that we need
  90.     ret                             ;routine done!
  91. _   ld a,(_cursor)
  92.     cp 7
  93.         jr nc,_ ;if _cursor is >=8 go to other method
  94.     add a,a
  95.     ld b,a
  96.     add a,a
  97.     add a,b
  98.     add a,16    ;a*6+16
  99.     ld l,a
  100.     ld a,6
  101.     ret
  102. _   ld b,7
  103. _   cp 7
  104.         jr nz,_
  105.     ld l,16
  106.     jr ++_
  107. _   ld l,22
  108. _   ld a,48
  109.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement