Upload files to "programs/games/arkanoid"
Build system / Check kernel codestyle (pull_request) Successful in 2m49s
Build system / Build (pull_request) Failing after 3h3m23s

Big font, slightly smaller size after compilation.
This commit is contained in:
Max
2026-03-21 11:28:42 +00:00
parent ddafae8913
commit 9c2d83ec08
+167 -112
View File
@@ -1,5 +1,5 @@
; ==================
; ARKANOID INFINITE
; ARCANOID INFINITE
; ==================
; SPDX-License-Identifier: GPL-2.0-only
; Program - Lbreakout clone game
@@ -23,12 +23,12 @@ dd 0, 0
; --- CONSTANTS ---
WIN_W equ 550
WIN_H equ 620
WIN_H equ 553
CLR_WINDOW_BG equ 0xACE1AF
GAME_W equ 380
GAME_H equ 500
GAME_X equ 25
GAME_Y equ 25
GAME_X equ 13
GAME_Y equ 13
BPP equ 3
STRIDE equ GAME_W * BPP
BRICK_W equ 40
@@ -75,16 +75,23 @@ on_key:
cmp al, 'N'
je close_app
jmp event_loop
draw_input_area:
pushad
mov eax,13
mov ebx, 420 shl 16 + 80
mov ecx, 200 shl 16 + 15
mov ebx, 420 shl 16 + 100
mov ecx, 205 shl 16 + 25
mov edx, CLR_WINDOW_BG
int 0x40
mov eax, 4
mov ebx, 420 shl 16 + 200
mov ecx, 0xFF00FF
mov ebx, 420 shl 16 + 190
mov ecx, 0xB0000000 + 0xFF0000
mov edx, new_hs_txt
mov esi, 14
int 0x40
mov eax, 4
mov ebx, 420 shl 16 + 215
mov ecx, 0xB0000000 + 0xFF00FF
mov edx, new_name
mov esi, 8
int 0x40
@@ -105,6 +112,7 @@ handle_name_input:
jae event_loop
mov [new_name + ecx], al
inc dword [name_ptr]
mov byte [new_name + ecx + 1], 0
call draw_input_area
jmp event_loop
.backspace:
@@ -134,28 +142,30 @@ on_redraw:
jmp event_loop
reset_game:
mov dword [score], 0
mov dword [lives], 4
mov dword [current_level], 1
xor eax, eax
mov [score], eax
mov [ball_active], eax
mov [old_score], eax
mov [old_lives], eax
mov [old_level], eax
push 4
pop [lives]
inc eax
mov [current_level], eax
mov edi, score_buffer
mov ecx, 8
mov ecx, 24
xor eax, eax
rep stosd
mov edi, level_buffer
mov ecx, 8
rep stosd
mov dword [ball_active], 0
mov dword [old_score], -1
mov dword [old_lives], -1
mov dword [old_level], -1
call generate_random_level
call draw_full_window
jmp event_loop
no_more_events:
cmp dword [lives], 0
cmp [lives], 0
jle .render_only
cmp dword [input_mode], 1
cmp [input_mode], 1
je .render_only
mcall 37, 1
shr eax, 16
@@ -197,7 +207,6 @@ no_more_events:
jmp event_loop
; --- HIGH SCORE LOGIC ---
load_highscores:
pushad
mov [file_info.op], 0
@@ -211,21 +220,15 @@ load_highscores:
ret
.create_default:
mov edi, hs_data
mov ecx, 60 / 4
xor eax, eax
rep stosd
mov edi, hs_data
mov ecx, 5
mov ecx, 5
.init_loop:
push ecx
mov esi, default_name
mov ecx, 8
rep movsb
mov eax, 'PLAY'
stosd
mov eax, 'ER__'
stosd
xor eax, eax
stosd
pop ecx
loop .init_loop
call save_highscores
popad
ret
@@ -255,12 +258,12 @@ check_if_highscore:
mov dword [input_mode], 1
mov dword [name_ptr], 0
mov edi, new_name
mov al, '-'
mov al, ' '
mov ecx, 8
rep stosb
call draw_input_area
ret
insert_highscore:
pushad
mov eax, [score]
@@ -274,15 +277,12 @@ insert_highscore:
popad
ret
.found:
; edi holds the address of the record being displaced
push edi ecx
; Shift from the end of the list up to the edi position
mov esi, hs_data + 48 ; start of the last (5th) record
mov edx, hs_data + 60 ; end of buffer
.move_loop:
cmp esi, edi
je .done_move
; Copy record [esi-12] to [esi]
push esi edi
mov edi, esi
sub esi, 12
@@ -293,7 +293,6 @@ insert_highscore:
jmp .move_loop
.done_move:
pop ecx edi
; Insert new record at edi location
mov esi, new_name
mov ecx, 8
rep movsb
@@ -303,7 +302,6 @@ insert_highscore:
popad
ret
; --- BALL MECHANICS ---
move_ball:
mov eax, [ball_x]
@@ -436,89 +434,137 @@ check_bricks:
draw_full_window:
mcall SF_REDRAW, SSF_BEGIN_DRAW
mcall SF_CREATE_WINDOW, <100, WIN_W>, <100, WIN_H>, 0x33000000 + CLR_WINDOW_BG, 0, title
mcall SF_DRAW_TEXT, <420, 30>, 0x0000FF, score_txt, 5
mcall SF_DRAW_TEXT, <420, 75>, 0x000000, lives_txt, 5
mcall SF_DRAW_TEXT, <420, 125>, 0x555555, level_txt, 5
mcall SF_DRAW_TEXT, <420, 280>, 0x8B0000, hs_title, 11
; SCORE
mov eax, 4
mov ebx, 420 shl 16 + 30
mov ecx, 0xB0000000 + 0x0000FF ; Big Font + Blue
mov edx, score_txt
mov esi, 5
int 0x40
; LIVES
mov ebx, 420 shl 16 + 90
mov ecx, 0xB0000000 + 0x000000 ; Big Font + Black
mov edx, lives_txt
mov esi, 5
int 0x40
; LEVEL
mov ebx, 420 shl 16 + 150
mov ecx, 0xB0000000 + 0x555555 ; Big Font + Gray
mov edx, level_txt
mov esi, 5
int 0x40
; HIGH SCORES
mov ebx, 420 shl 16 + 300
mov ecx, 0xB0000000 + 0x8B0000
mov edx, hs_title
mov esi, 11
int 0x40
.hs_draw:
mov esi, hs_data
mov dword [temp_y], 300
mov dword [temp_y], 340
mov ecx, 5
.hs_loop:
push ecx
push esi
mov eax, 4
mov ebx, 420
shl ebx, 16
add ebx, [temp_y]
mov ecx, 0x000000
mov edx, esi
mov esi, 8
int 0x40
pop esi
push esi
mov ebx, 420 shl 16
add ebx, [temp_y]
mov ecx, 0xB0000000 + 0x000000
mov edx, esi
mov esi, 8
int 0x40
pop esi
push esi
mov eax, [esi+8]
mov edi, hs_temp_buf
call int_to_string
mov edx, hs_temp_buf
mov esi, eax
mov eax, 4
mov ebx, 500
shl ebx, 16
mov ebx, 495 shl 16
add ebx, [temp_y]
mov ecx, 0x000000
mov ecx, 0xB0000000 + 0x000000
int 0x40
pop esi
pop ecx
add esi, 12
add dword [temp_y], 20
add dword [temp_y], 25
dec ecx
jnz .hs_loop
jmp .hs_finish_up
.hs_finish_up:
.hs_finish_up:
mov dword [old_score], -1
mov dword [old_lives], -1
mov dword [old_level], -1
call update_dynamic_stats
call render_buffer
mcall SF_REDRAW, SSF_END_DRAW
ret
update_dynamic_stats:
pushad
; SCORE
; --- SCORE VALUE ---
mov eax, [score]
cmp eax, [old_score]
je .skip_score
mov edi, score_buffer
push eax
mov eax, [old_score]
cmp eax, -1
je .no_old_s
call int_to_string
mcall SF_DRAW_TEXT, <420, 50>, CLR_WINDOW_BG, score_buffer, edx
mov eax, 4
mov ebx, 420 shl 16 + 55
mov ecx, 0xB0000000 + CLR_WINDOW_BG
mov edx, score_buffer
mov esi, 10
int 0x40
.no_old_s:
pop eax
mov [old_score], eax
mov edi, score_buffer
call int_to_string
mcall SF_DRAW_TEXT, <420, 50>, 0x0000FF, score_buffer, edx
.skip_score:
mov esi, eax
mov eax, 4
mov ebx, 420 shl 16 + 55
mov ecx, 0xB0000000 + 0x0000FF
mov edx, score_buffer
int 0x40
; LIVES
.skip_score:
; --- LIVES VALUE ---
mov eax, [lives]
cmp eax, [old_lives]
je .skip_lives
mov edi, lives_buffer
push eax
mov eax, [old_lives]
cmp eax, -1
je .no_old_l
call int_to_string
mcall SF_DRAW_TEXT, <420, 95>, CLR_WINDOW_BG, lives_buffer, edx
mov eax, 4
mov ebx, 420 shl 16 + 110
mov ecx, 0xB0000000 + CLR_WINDOW_BG
mov edx, lives_buffer
mov esi, 2
int 0x40
.no_old_l:
pop eax
mov [old_lives], eax
@@ -526,45 +572,69 @@ update_dynamic_stats:
jle .over
mov edi, lives_buffer
call int_to_string
mcall SF_DRAW_TEXT, <420, 95>, 0x000000, lives_buffer, edx
.skip_lives:
mov esi, eax
mov eax, 4
mov ebx, 420 shl 16 + 110
mov ecx, 0xB0000000 + 0x000000
mov edx, lives_buffer
int 0x40
; LEVEL
.skip_lives:
; --- LEVEL VALUE ---
mov eax, [current_level]
cmp eax, [old_level]
je .skip_level
mov edi, level_buffer
push eax
mov eax, [old_level]
cmp eax, -1
je .no_old_v
call int_to_string
mcall SF_DRAW_TEXT, <420, 145>, CLR_WINDOW_BG, level_buffer, edx
mov eax, 4
mov ebx, 420 shl 16 + 165
mov ecx, 0xB0000000 + CLR_WINDOW_BG
mov edx, level_buffer
mov esi, 2
int 0x40
.no_old_v:
pop eax
mov [old_level], eax
mov edi, level_buffer
call int_to_string
mcall SF_DRAW_TEXT, <420, 145>, 0x555555, level_buffer, edx
mov esi, eax
mov eax, 4
mov ebx, 420 shl 16 + 165
mov ecx, 0xB0000000 + 0x555555
mov edx, level_buffer
int 0x40
.skip_level:
popad
ret
.over:
cmp dword [input_mode], 1
je .input_ui
mcall SF_DRAW_TEXT, <420, 180>, 0x000000, again_txt, 11
mcall SF_DRAW_TEXT, <420, 200>, 0x000000, y_n_txt, 3
mcall SF_DRAW_TEXT, <420, 95>, 0xFF0000, over_txt, 9
popad
ret
.input_ui:
mcall SF_DRAW_TEXT, <420, 180>, 0x0000FF, new_hs_txt, 13
mcall SF_DRAW_TEXT, <420, 200>, 0xFF00FF, new_name, 8
mcall SF_DRAW_TEXT, <420, 220>, 0x000000, enter_txt, 13
popad
ret
; GAME OVER messages
mov eax, 4
mov ebx, 420 shl 16 + 110
mov ecx, 0xB0000000 + 0xFF0000
mov edx, over_txt
mov esi, 9
int 0x40
mov ebx, 420 shl 16 + 250
mov ecx, 0xB0000000 + 0x000000
mov edx, again_txt
mov esi, 11
int 0x40
mov ebx, 420 shl 16 + 270
mov edx, y_n_txt
mov esi, 3
int 0x40
popad
ret
; --- HELPERS ---
int_to_string:
push ebx
@@ -794,7 +864,6 @@ draw_ball:
popad
ret
; --- DATA ---
DATA
title db 'Arkanoid Infinite', 0
@@ -806,9 +875,6 @@ DATA
y_n_txt db 'Y/N', 0
hs_title db 'HIGH SCORES', 0
new_hs_txt db 'NEW HIGHSCORE!', 0
enter_txt db 'PRESS ENTER...', 0
default_name db 'PLAYER--'
align 4
paddle_x dd 150
ball_active dd 0
ball_x dd 0
@@ -828,16 +894,6 @@ DATA
name_ptr dd 0
align 4
hs_data:
db 'PLAYER--', 0, 0, 0, 0
db 'PLAYER--', 0, 0, 0, 0
db 'PLAYER--', 0, 0, 0, 0
db 'PLAYER--', 0, 0, 0, 0
db 'PLAYER--', 0, 0, 0, 0
align 4
file_info:
.op dd 0
.pos dd 0
@@ -847,22 +903,21 @@ align 4
.rsvd db 0
.path dd 0
align 4
HS_FILE db '/rd/1/GAMES/arkanoid.hs',0
align 4
hs_temp_buf: db 32 dup (0)
score_buffer: db 32 dup (0)
lives_buffer: db 32 dup (0)
level_buffer: db 32 dup (0)
new_name db '--------'
i_end:
virtual at $
align 64
active_map: rb 128
screen_buffer: rb GAME_W * GAME_H * 3 + 8192
align 16
hs_data: rb 60
active_map: rb 256
screen_buffer: rb (GAME_W * GAME_H * 3) + 1024
hs_temp_buf rb 32
score_buffer rb 32
lives_buffer rb 32
level_buffer rb 32
new_name rb 16
rb 4096
stacktop:
mem_end:
end virtual