mirror of
https://github.com/UzixLS/zx-midiplayer.git
synced 2025-07-19 07:11:26 +03:00
load next file if current playing song is over or user has pressed enter key in player
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
function screen_address_pixel(x, y, baseaddr)
|
||||
baseaddr = baseaddr or 0x4000
|
||||
if( not (x >= 0 and x < 256 and y >= 0 and y < 192)) then
|
||||
if (not (x >= 0 and x < 256 and y >= 0 and y < 192)) then
|
||||
sj.error("[screen_address_pixel]: invalid argument x=" .. x .. " y=" .. y)
|
||||
return 0
|
||||
end
|
||||
@ -9,7 +9,7 @@ end
|
||||
|
||||
function screen_address_attr(x, y, baseaddr)
|
||||
baseaddr = baseaddr or 0x4000
|
||||
if( not (x >= 0 and x < 256 and y >= 0 and y < 192)) then
|
||||
if (not (x >= 0 and x < 256 and y >= 0 and y < 192)) then
|
||||
sj.error("[screen_address_attr]: invalid argument x=" .. x .. " y=" .. y)
|
||||
return 0
|
||||
end
|
||||
|
@ -3,3 +3,5 @@ INPUT_REPEAT_FIRST equ 11
|
||||
INPUT_BEEP_DELAY equ 20
|
||||
|
||||
PIANO_KEYS_FIRST equ 12
|
||||
|
||||
LOAD_NEXT_FILE_DELAY equ 10
|
||||
|
@ -184,6 +184,13 @@ input_process:
|
||||
ret ;
|
||||
|
||||
|
||||
; IN - A - key
|
||||
input_simulate_keypress:
|
||||
ld (var_input_key), a ;
|
||||
ld (var_input_key_last), a ;
|
||||
ret ;
|
||||
|
||||
|
||||
; OUT - AF - garbage
|
||||
input_detect_kempston:
|
||||
ei : halt ; avoid collision with attribute port
|
||||
|
39
src/main.asm
39
src/main.asm
@ -4,6 +4,8 @@
|
||||
DEVICE ZXSPECTRUM128,stack_top
|
||||
|
||||
includelua "lua/screen_address.lua"
|
||||
include "config.inc"
|
||||
include "layout.inc"
|
||||
|
||||
page 0
|
||||
org int_handler-(variables0_end-variables0)
|
||||
@ -61,15 +63,31 @@ main:
|
||||
|
||||
|
||||
play_file:
|
||||
ld ix, file_base_addr ;
|
||||
call smf_parse ;
|
||||
ret nz ;
|
||||
call load_screen1 ;
|
||||
call player_loop ;
|
||||
call load_screen0 ;
|
||||
ld iy, file_menu ;
|
||||
call menu_draw ;
|
||||
ret ;
|
||||
ld ix, file_base_addr ;
|
||||
call smf_parse ;
|
||||
ret nz ;
|
||||
call load_screen1 ;
|
||||
call player_loop ;
|
||||
call load_screen0 ;
|
||||
ld iy, file_menu ;
|
||||
call menu_draw ;
|
||||
ld a, (var_player_nextfile_flag) ; if nextfile flag is set - load next file
|
||||
dec a ; ...
|
||||
ret nz ; ... or exit if isn't set
|
||||
.load_next_file:
|
||||
ld (var_player_nextfile_flag), a ; reset nextfile flag
|
||||
ld b, LOAD_NEXT_FILE_DELAY ; just cosmetic delay
|
||||
1: ei : halt ; ...
|
||||
djnz 1b ; ...
|
||||
ld a, INPUT_KEY_DOWN ; move cursor down
|
||||
call input_simulate_keypress ; ...
|
||||
call menu_handle_input ; ...
|
||||
ld b, LOAD_NEXT_FILE_DELAY ; just cosmetic delay
|
||||
1: ei : halt ; ...
|
||||
djnz 1b ; ...
|
||||
ld a, INPUT_KEY_ACT ; load file
|
||||
call input_simulate_keypress ; ...
|
||||
jp menu_handle_input ; ...
|
||||
|
||||
|
||||
; IN - DE - entry number (assume < 128)
|
||||
@ -80,9 +98,6 @@ file_menu_callback:
|
||||
pop de
|
||||
ret
|
||||
|
||||
include "config.inc"
|
||||
include "layout.inc"
|
||||
|
||||
include "input.asm"
|
||||
include "menu.asm"
|
||||
include "file.asm"
|
||||
|
@ -41,7 +41,7 @@ player_loop:
|
||||
call smf_get_tempo ;
|
||||
call player_set_tempo ;
|
||||
.loop:
|
||||
push hl ;
|
||||
push hl ;
|
||||
call vis_process_frame ;
|
||||
call player_update_timer ;
|
||||
pop hl ;
|
||||
@ -52,9 +52,11 @@ player_loop:
|
||||
ld a, (var_input_key) ;
|
||||
cp INPUT_KEY_BACK ;
|
||||
jr z, .end ;
|
||||
cp INPUT_KEY_ACT ;
|
||||
jr z, .load_next_file ;
|
||||
.process_tracks:
|
||||
call smf_get_first_track ;
|
||||
jr z, .end ;
|
||||
jr z, .load_next_file ;
|
||||
.process_current_track:
|
||||
call smf_process_track ; A = status, HL = track position, BC = data len
|
||||
jp c, .next_track ; if C == 1 (delayed) then go to the next track
|
||||
@ -65,9 +67,9 @@ player_loop:
|
||||
call smf_handle_meta ; ... instead, process it locally. HL = next track position
|
||||
jp .process_current_track ; ...
|
||||
.vis:
|
||||
push bc
|
||||
call vis_process_command
|
||||
pop bc
|
||||
push bc ;
|
||||
call vis_process_command ;
|
||||
pop bc ;
|
||||
.status_send:
|
||||
ld ixh, b : ld ixl, c ; IX = data len
|
||||
di : call uart_putc : ei ; send status
|
||||
@ -83,6 +85,9 @@ player_loop:
|
||||
call smf_get_next_track ;
|
||||
jr z, .loop ;
|
||||
jp .process_current_track ;
|
||||
.load_next_file:
|
||||
ld a, 1 ;
|
||||
ld (var_player_nextfile_flag), a ;
|
||||
.end:
|
||||
; jp player_reset_chip ;
|
||||
|
||||
|
@ -26,6 +26,7 @@ var_smf_file smf_file_t
|
||||
var_tmp32 BLOCK 32
|
||||
|
||||
var_player_state player_state_t
|
||||
var_player_nextfile_flag BYTE 0
|
||||
|
||||
var_vis_state vis_state_t
|
||||
|
||||
|
10
src/vis.asm
10
src/vis.asm
@ -17,13 +17,10 @@ vis_piano_key_addresses:
|
||||
n = key % 12
|
||||
if n==1 or n==3 or n==6 or n==8 or n==10 then
|
||||
y_offset = _c("LAYOUT_PIANO_KEYS_Y_BLACK")
|
||||
else
|
||||
y_offset = 0;
|
||||
end
|
||||
if n==0 or n==2 or n==4 or n==5 or n==7 or n==9 or n==11 then
|
||||
x_append = 8
|
||||
else
|
||||
x_append = 0
|
||||
else
|
||||
y_offset = 0
|
||||
x_append = 8
|
||||
end
|
||||
address = screen_address_pixel(x, y + y_offset)
|
||||
if y_offset ~= 0 then
|
||||
@ -198,7 +195,6 @@ vis_process_frame:
|
||||
call get_pixel_address ;
|
||||
xor a ;
|
||||
ld (hl), a ;
|
||||
nop
|
||||
.next_chan:
|
||||
dec e ;
|
||||
jp p, .loop_next_chan ;
|
||||
|
Reference in New Issue
Block a user