You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
227 lines
5.1 KiB
227 lines
5.1 KiB
.include "instr.inc"
|
|
.text
|
|
|
|
.global _start
|
|
_start:
|
|
# Set up the stack
|
|
ld_sp mem_stack
|
|
copr_random
|
|
str_r0 mem_stack_tail
|
|
str_r0 mem_stack_cookie
|
|
copr_random
|
|
str_r0 mem_stack_tail + 2
|
|
str_r0 mem_stack_cookie + 2
|
|
|
|
# Prompt for username
|
|
ld_r2 str_login
|
|
call PrintStr
|
|
ld_r2 mem_username
|
|
ld_r3 15
|
|
call ReadStr
|
|
ld_r2 mem_username
|
|
call StrTrim
|
|
|
|
call main
|
|
|
|
ld_r2 str_done
|
|
call PrintStr
|
|
|
|
copr_halt
|
|
die:
|
|
jp die
|
|
|
|
main:
|
|
# Welcome the user
|
|
ld_r2 str_welcome
|
|
call PrintStr
|
|
ld_r2 mem_username
|
|
call PrintStr
|
|
ld_r2 str_welcome2
|
|
call PrintStr
|
|
|
|
# Process input
|
|
ld_r2 mem_input
|
|
call input_read
|
|
ldrb_r0 mem_input
|
|
cp_r0 'Q'
|
|
jp_eq main_end
|
|
cp_r0 'q'
|
|
jp_eq main_end
|
|
ldrb_r0 mem_input + 1
|
|
cp_r0 '\n'
|
|
jp_eq main_print_info
|
|
cp_r0 0
|
|
jp_eq main_print_info
|
|
jp main_wrong_input
|
|
|
|
main_print_info:
|
|
# Get info index
|
|
ldrb_r3 mem_input
|
|
add_r3 -'0'
|
|
cp_r3 3
|
|
jp_lo main_wrong_input
|
|
|
|
# Print the correct string
|
|
add_r3_r3
|
|
add_r3 mem_info_strings
|
|
ldr_r2_r3
|
|
call PrintStr
|
|
jp main
|
|
|
|
main_wrong_input:
|
|
ld_r2 str_wrong_input
|
|
call PrintStr
|
|
ld_r3 0x1000
|
|
jp main
|
|
|
|
main_end:
|
|
# Check for stack smash
|
|
ldr_r0 mem_stack_cookie
|
|
ldr_r1 mem_stack_tail
|
|
cp_r0_r1
|
|
jp_ne stack_smash_halt
|
|
ldr_r0 mem_stack_cookie + 2
|
|
ldr_r1 mem_stack_tail + 2
|
|
cp_r0_r1
|
|
jp_ne stack_smash_halt
|
|
ret
|
|
|
|
input_read:
|
|
# Store the byte
|
|
copr_getc
|
|
strb_r0_r2
|
|
|
|
# Treat newline as delimiter
|
|
cp_r0 '\n'
|
|
jp_eq input_read_end
|
|
|
|
# Don't increment if ran out of space
|
|
cp_r3 0
|
|
jp_eq input_read_skip
|
|
inc_r2
|
|
dec_r3
|
|
input_read_skip:
|
|
jp input_read
|
|
|
|
input_read_end:
|
|
# Terminate the string
|
|
inc_r2
|
|
ld_r0 0
|
|
strb_r0_r2
|
|
|
|
# Check for stack smash
|
|
ldr_r0 mem_stack_cookie
|
|
ldr_r1 mem_stack_tail
|
|
cp_r0_r1
|
|
jp_ne stack_smash_halt
|
|
ldr_r0 mem_stack_cookie + 2
|
|
ldr_r1 mem_stack_tail + 2
|
|
cp_r0_r1
|
|
jp_ne stack_smash_halt
|
|
ret
|
|
|
|
stack_smash_halt:
|
|
ld_r2 str_stack_smashing_detected
|
|
call PrintStr
|
|
copr_halt
|
|
|
|
str_stack_smashing_detected:
|
|
.ascii "*** stack smashing detected *** "
|
|
text_ram_byte 0xfe00
|
|
text_ram_byte 0xfe01
|
|
text_ram_byte 0xfe02
|
|
text_ram_byte 0xfe03
|
|
.ascii " != "
|
|
text_ram_byte 0xf74f
|
|
text_ram_byte 0xf750
|
|
text_ram_byte 0xf751
|
|
text_ram_byte 0xf752
|
|
.ascii " - halted\n\0"
|
|
|
|
str_login:
|
|
.ascii "Welcome to Glitch Research Lab Information Server (GRLINFSRV)\n"
|
|
.ascii "Enter your name for our records (max 15 characters): \0"
|
|
|
|
str_welcome:
|
|
.ascii "\n"
|
|
.ascii "-----\n"
|
|
.ascii "\n"
|
|
.ascii "Welcome, \0"
|
|
|
|
str_welcome2:
|
|
.ascii "!\n"
|
|
.ascii "\n"
|
|
.ascii "Selection of topics:\n"
|
|
.ascii "(1) About the Glitch Research Laboratory\n"
|
|
.ascii "(2) About the GLVM test servers\n"
|
|
.ascii "(3) About the Fight Simulation Program\n"
|
|
.ascii "\n"
|
|
.ascii "Enter the number of the topic you wish to view, or 'q' to leave: \0"
|
|
|
|
str_done:
|
|
.ascii "Thank you. Have a nice day!\n\0"
|
|
|
|
mem_info_strings:
|
|
.2byte str_wrong_input
|
|
.2byte str_info_1
|
|
.2byte str_info_2
|
|
.2byte str_info_3
|
|
|
|
str_wrong_input:
|
|
.ascii "Please type 1, 2 or 3, dummy!\n\0"
|
|
|
|
str_info_1:
|
|
.ascii "\n"
|
|
.ascii "-----\n"
|
|
.ascii "\n"
|
|
.ascii "Glitch Research Laboratory is the leading glitchology research\n"
|
|
.ascii "facility in all of Glitch Islands. We specialize in research of\n"
|
|
.ascii "various glitch phenomena existing in Glitch Islands and in all of\n"
|
|
.ascii "the surrounding areas.\n"
|
|
.ascii "\0"
|
|
|
|
str_info_2:
|
|
.ascii "\n"
|
|
.ascii "-----\n"
|
|
.ascii "\n"
|
|
.ascii "GLVM is our innovative, new machine architecture, designed to bring\n"
|
|
.ascii "the ease of Z80 assembly programming to the modern world.\n"
|
|
.ascii "The simplified instruction set of the GLVM enhances productivity\n"
|
|
.ascii "of our employees and significantly speeds up development of software\n"
|
|
.ascii "required for our research.\n"
|
|
.ascii "Work on the GLVM architecture is still ongoing, and all implementation\n"
|
|
.ascii "details are strictly confidential, until further notice.\n"
|
|
.ascii "\0"
|
|
|
|
str_info_3:
|
|
.ascii "\n"
|
|
.ascii "-----\n"
|
|
.ascii "\n"
|
|
.ascii "Fight Simulation Program is the current ongoing project of Glitch\n"
|
|
.ascii "Research Laboratory. It allows for examination of behavior of\n"
|
|
.ascii "malicious glitch actors, such as Missingno., without running the risk\n"
|
|
.ascii "of prolonged exposure to glitches or corruption.\n"
|
|
.ascii "Participants are able to fight against opponents in an isolated\n"
|
|
.ascii "environment, similar to typical turn-based strategy games.\n"
|
|
.ascii "The program is still in development, and as such, all details are\n"
|
|
.ascii "strictly confidential.\n"
|
|
.ascii "\0"
|
|
|
|
.ascii "FOOLS2023_{DoesThisCountAsFormatString}\n\0"
|
|
|
|
mem_username:
|
|
.ascii "________________"
|
|
|
|
mem_stack_cookie:
|
|
.fill 4, 1, 0
|
|
|
|
mem_input:
|
|
.ascii "________"
|
|
|
|
.fill 0x6a5, 1, 0
|
|
|
|
mem_stack_tail:
|
|
.fill 0x100, 1, 0
|
|
|
|
mem_stack:
|
|
.fill 0x100, 1, 0
|
|
|