;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.6.8 #9946 (CYGWIN)
;--------------------------------------------------------
	.module menu
	.optsdcc -mz80
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _menu
	.globl _renderScore
	.globl _initScreen
	.globl _fade
	.globl _updatePalette
	.globl _clearScreens
	.globl _mydrawStringM1
	.globl _waitBorder
	.globl _cpct_zx7b_decrunch_s
	.globl _cpct_restoreState_mxor_u8
	.globl _cpct_setSeed_mxor
	.globl _cpct_getRandom_mxor_u8
	.globl _cpct_akp_stop
	.globl _cpct_akp_musicInit
	.globl _cpct_setPALColour
	.globl _cpct_drawSpriteMasked
	.globl _cpct_drawSprite
	.globl _cpct_isAnyKeyPressed_f
	.globl _cpct_isKeyPressed
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area _DATA
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
	.area _INITIALIZED
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
	.area _DABS (ABS)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area _HOME
	.area _GSINIT
	.area _GSFINAL
	.area _GSINIT
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area _HOME
	.area _HOME
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area _CODE
;src/menu.c:10: void menu() {
;	---------------------------------
; Function menu
; ---------------------------------
_menu::
	call	___sdcc_enter_ix
	dec	sp
;src/menu.c:15: cpct_akp_musicInit((u8*) m_menu);
	ld	bc, #_m_menu+0
	push	bc
	call	_cpct_akp_musicInit
	pop	af
;src/menu.c:16: music_playing = 1;	
	ld	hl,#_music_playing + 0
	ld	(hl), #0x01
;src/menu.c:18: clearScreens();
	call	_clearScreens
;src/menu.c:19: *(u8*)&paletteM0[3] = HW_PASTEL_CYAN;
	ld	hl, #(_paletteM0 + 0x0003)
	ld	(hl), #0x1b
;src/menu.c:20: updatePalette();
	call	_updatePalette
;src/menu.c:22: start = 0;
	ld	-1 (ix), #0x00
;src/menu.c:23: delay = 65535;
	ld	de, #0xffff
;src/menu.c:25: spriteset = (u8*) &G_sprite_f1[0];
	ld	bc, #_G_sprite_f1+0
	ld	(_spriteset), bc
;src/menu.c:26: faces = (u8*) &G_face0[0];
	ld	hl, #_G_face0+0
	ld	(_faces), hl
;src/menu.c:27: extra_char = 0;
	ld	hl,#_extra_char + 0
	ld	(hl), #0x00
;src/menu.c:29: while (!start) {
00119$:
	ld	a, -1 (ix)
	or	a, a
	jp	NZ, 00121$
;src/menu.c:30: screen = cpct_rand() % 21; 
	call	_cpct_getRandom_mxor_u8
	ld	b, l
	ld	a, #0x15
	push	af
	inc	sp
	push	bc
	inc	sp
	call	__moduchar
	pop	af
	ld	iy, #_screen
	ld	0 (iy), l
;src/menu.c:31: mode = 2;
	ld	b, #0x02
;src/menu.c:32: while (mode == 2) { 
00101$:
	ld	a, b
	sub	a, #0x02
	jr	NZ,00103$
;src/menu.c:33: mode = cpct_rand() % 5;
	call	_cpct_getRandom_mxor_u8
	ld	b, l
	ld	a, #0x05
	push	af
	inc	sp
	push	bc
	inc	sp
	call	__moduchar
	pop	af
	ld	b, l
	jr	00101$
00103$:
;src/menu.c:35: mode = mode - 2; // Para que mode tenga valores -2, -1, 1 y 2
	dec	b
	dec	b
;src/menu.c:36: waitBorder();
	push	bc
	call	_waitBorder
	inc	sp
	call	_initScreen
	inc	sp
;src/menu.c:41: cpct_zx7b_decrunch_s((void *) (&current_map[0] + calendar_size - 1),(u8 *) calendar_end);
	ld	de, #(_calendar + 0x00a2)
	ld	bc, #(_current_map + 0x03cb)
	push	de
	push	bc
	call	_cpct_zx7b_decrunch_s
;src/menu.c:42: cpct_drawSprite (&current_map[0],  cpctm_screenPtr (CPCT_VMEM_START, 21, 148),27, 36);
	ld	hl, #0x241b
	push	hl
	ld	hl, #0xe5b5
	push	hl
	ld	hl, #_current_map
	push	hl
	call	_cpct_drawSprite
;src/menu.c:43: cpct_drawSpriteMasked (&G_sprite_f1[0], cpctm_screenPtr (CPCT_VMEM_START, 44, 171), 3, 16);
	ld	hl, #0x1003
	push	hl
	ld	hl, #0xdebc
	push	hl
	ld	hl, #_G_sprite_f1
	push	hl
	call	_cpct_drawSpriteMasked
;src/menu.c:45: mydrawStringM1(txt_highscore, cpctm_screenPtr(CPCT_VMEM_START, 0, 192));
	ld	hl, #0xc780
	push	hl
	ld	hl, #_txt_highscore
	push	hl
	call	_mydrawStringM1
;src/menu.c:46: renderScore(hiscore);
	ld	a, (_hiscore)
	push	af
	inc	sp
	call	_renderScore
	inc	sp
;src/menu.c:48: delay = 65535;
	ld	de, #0xffff
;src/menu.c:49: while (delay) {
	ld	bc, #0xffff
00116$:
	ld	a, b
	or	a,c
	jp	Z, 00119$
;src/menu.c:51: if (cpct_isAnyKeyPressed_f()) {
	push	bc
	push	de
	call	_cpct_isAnyKeyPressed_f
	pop	de
	pop	bc
	ld	a, l
	or	a, a
	jr	Z,00105$
;src/menu.c:52: start = 1;
	ld	-1 (ix), #0x01
;src/menu.c:53: break;
	jp	00119$
00105$:
;src/menu.c:56: if (delay == 65535) 
	ld	a, c
	inc	a
	jr	NZ,00107$
	ld	a, b
	inc	a
	jr	NZ,00107$
;src/menu.c:57: mydrawStringM1(txt_pressKey, cpctm_screenPtr(CPCT_VMEM_START, 36, 192));
	push	bc
	ld	hl, #0xc7a4
	push	hl
	ld	hl, #_txt_pressKey
	push	hl
	call	_mydrawStringM1
	pop	bc
00107$:
;src/menu.c:58: if (delay == 52428)
	ld	a, c
	sub	a, #0xcc
	jr	NZ,00109$
	ld	a, b
	sub	a, #0xcc
	jr	NZ,00109$
;src/menu.c:59: mydrawStringM1(txt_credits1, cpctm_screenPtr(CPCT_VMEM_START, 36, 192));
	push	bc
	ld	hl, #0xc7a4
	push	hl
	ld	hl, #_txt_credits1
	push	hl
	call	_mydrawStringM1
	pop	bc
00109$:
;src/menu.c:60: if (delay == 39321)
	ld	a, c
	sub	a, #0x99
	jr	NZ,00111$
	ld	a, b
	sub	a, #0x99
	jr	NZ,00111$
;src/menu.c:61: mydrawStringM1(txt_credits2, cpctm_screenPtr(CPCT_VMEM_START, 36, 192)); 
	push	bc
	ld	hl, #0xc7a4
	push	hl
	ld	hl, #_txt_credits2
	push	hl
	call	_mydrawStringM1
	pop	bc
00111$:
;src/menu.c:62: if (delay == 26214)
	ld	a, c
	sub	a, #0x66
	jr	NZ,00113$
	ld	a, b
	sub	a, #0x66
	jr	NZ,00113$
;src/menu.c:63: mydrawStringM1(txt_credits3, cpctm_screenPtr(CPCT_VMEM_START, 36, 192)); 
	push	bc
	ld	hl, #0xc7a4
	push	hl
	ld	hl, #_txt_credits3
	push	hl
	call	_mydrawStringM1
	pop	bc
00113$:
;src/menu.c:64: if (delay == 13107)
	ld	a, c
	sub	a, #0x33
	jr	NZ,00115$
	ld	a, b
	sub	a, #0x33
	jr	NZ,00115$
;src/menu.c:65: mydrawStringM1(txt_credits4, cpctm_screenPtr(CPCT_VMEM_START, 36, 192));
	push	bc
	ld	hl, #0xc7a4
	push	hl
	ld	hl, #_txt_credits4
	push	hl
	call	_mydrawStringM1
	pop	bc
00115$:
;src/menu.c:66: delay--;
	dec	bc
	ld	e, c
	ld	d, b
	jp	00116$
00121$:
;src/menu.c:70: seed = (u8) delay;
;src/menu.c:71: cpct_srand8(seed);
	ld	d, #0x00
	ld	hl,#0x0000
	ex	de, hl
	call	_cpct_setSeed_mxor
	call	_cpct_restoreState_mxor_u8
;src/menu.c:73: for (delay = 0; delay < 1024; delay++) {
	ld	bc, #0x0000
00126$:
;src/menu.c:74: if (cpct_isKeyPressed(Key_Z) && cpct_isKeyPressed(Key_X)) {
	push	bc
	ld	hl, #0x8008
	call	_cpct_isKeyPressed
	pop	bc
	ld	a, l
	or	a, a
	jr	Z,00127$
	push	bc
	ld	hl, #0x8007
	call	_cpct_isKeyPressed
	pop	bc
	ld	a, l
	or	a, a
	jr	Z,00127$
;src/menu.c:75: cpct_setBorder( paletteM0 [((u8) delay % 16)]);
	ld	a, c
	and	a, #0x0f
	ld	e, a
	ld	hl, #_paletteM0
	ld	d, #0x00
	add	hl, de
	ld	d, (hl)
	push	bc
	ld	e, #0x10
	push	de
	call	_cpct_setPALColour
	pop	bc
;src/menu.c:76: spriteset = (u8*) &G_sprite_f1_COPY[0];
	ld	iy, #_spriteset
	ld	0 (iy), #<(_G_sprite_f1_COPY)
	ld	1 (iy), #>(_G_sprite_f1_COPY)
;src/menu.c:77: faces = (u8*) &G_face0_COPY[0];
	ld	iy, #_faces
	ld	0 (iy), #<(_G_face0_COPY)
	ld	1 (iy), #>(_G_face0_COPY)
;src/menu.c:78: extra_char = 1;
	ld	hl,#_extra_char + 0
	ld	(hl), #0x01
00127$:
;src/menu.c:73: for (delay = 0; delay < 1024; delay++) {
	inc	bc
	ld	a, b
	sub	a, #0x04
	jr	C,00126$
;src/menu.c:81: cpct_setBorder(HW_BLACK);
	ld	hl, #0x1410
	push	hl
	call	_cpct_setPALColour
;src/menu.c:85: music_playing = 0;
	ld	hl,#_music_playing + 0
	ld	(hl), #0x00
;src/menu.c:86: cpct_akp_stop ();
	call	_cpct_akp_stop
;src/menu.c:87: fade();
	call	_fade
	inc	sp
	pop	ix
	ret
	.area _CODE
	.area _INITIALIZER
	.area _CABS (ABS)
