Advertisement
Eeems

Magic Menu routine

Apr 9th, 2011
44
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.     xor a   ;set a 0
  5.     ld (_cursor),a
  6.     rectangle(5,4,75,61,0) \ rectangle(4,5,76,60,0)
  7.     largeSprite(4,4,9,57,MenuImg)
  8.     ld hl,(6*256)+6 ;set x
  9.     ld (penCol),hl  ;and y loc
  10.     wrappedtext(MagicMenuTitle)
  11.     ld a,6
  12.     ld (penCol),a
  13.     ld a,28
  14.     ld (penRow),a
  15.     call battle_magic_load_buf
  16.     wrappedtext(Text_buffer)
  17.     lcdupdate
  18. battle_magic_loop:
  19.         ;call name_menu_disp
  20.         b_call _getCSC
  21.         cp skUp
  22.             ;jr z,
  23.         cp skDown
  24.             ;jr z,
  25.         cp skAlpha
  26.             jr z,_
  27.         cp skClear
  28.             jr nz,battle_magic_loop
  29. _   call frombackbuff
  30.     jp battle_return
  31. battle_magic_load_buf:
  32.     call clearTextBuff  ;clear Text_buffer
  33.     ld hl,BlackMageStats+black  ;load start of magic table into hl
  34.     ld b,9  ;need to loop 9 times
  35.     ld c,0  ;incrementing position
  36.     ld de,Text_buffer
  37.     ld (tmpbuf),de  ;store Text buffer location for later
  38. _           push bc ;store b for later
  39.                 ld a,(hl)   ;test to see if this magic is enabled
  40.                 or a    ;z==false nz==true
  41.                     call nz,_   ;if it is write the string
  42.             pop bc
  43.             inc hl  ;increase position in magic table
  44.             inc c   ;increase position "pointer"
  45.         djnz -_ ;if (b-=1)!=0 goto last _
  46.     ret ;return, copying done
  47. _   push hl ;store location on magic table for later
  48.         call;get some stuff, whatev's
  49.         push hl ;got to work with hl
  50.             ld de,Magic_strings
  51.             ex de,hl    ;switch de and hl so I can work with de
  52.             sbc hl,de   ;can't remember...it works though
  53.             ld b,h  ;oh wait bc=(hl=hl-de) Why?
  54.             ld c,l  ;bc contains length of string
  55.         pop hl  ;now I need it back
  56.         ld de,(tmpbuf)  ;get the position in the string
  57.         ;ok so what the registers contain
  58.         ;bc = length of string
  59.         ;de = Text_buffer+offset
  60.         ;hl = Magic_strings+offset
  61.         ;af = poop
  62.         ldir    ;copy over the magic string to the Text_buffer+offset
  63.         ld a,'\n'   ;I'm a potato
  64.         ld (de),a   ;newline for formatting
  65.         ld (tmpbuf),de  ;store new Text_buffer+offset
  66.     pop hl
  67.     ret ;poop
  68. _   ld hl,Magic_strings ;store magic_strings array to hl
  69.     ld b,c  ;get the increasing pointer into b for loop
  70. _       inc hl  ;increase position
  71.         ld a,(hl)   ;test if 0
  72.         or a    ;if (hl)!=0
  73.             jr nz,-_    ;go back to _
  74.         djnz -_ ;elseif (b-=1)!=0 go back to _
  75.     inc hl  ;erm...wait! returns the location for after to use
  76.     ret ;I already told you; poop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement