mirror of
https://github.com/thiagoauler/apple1.git
synced 2025-02-06 20:30:04 +00:00
some handling for video output
This commit is contained in:
parent
f23c89dfce
commit
10e4cbbdb5
4
build.sh
4
build.sh
@ -9,7 +9,7 @@ rm -f $EXEC_NAME
|
||||
# build all source code
|
||||
for FILE in $SRC_FOLDER/*.c
|
||||
do
|
||||
cc -c $FILE
|
||||
cc -g -c $FILE
|
||||
done
|
||||
|
||||
# move all objects to appropriate folder
|
||||
@ -17,4 +17,4 @@ mkdir -p $OBJ_FOLDER
|
||||
mv *.o $OBJ_FOLDER
|
||||
|
||||
# create executable out of the objects
|
||||
cc -o $EXEC_NAME $OBJ_FOLDER/*.o
|
||||
cc -g -o $EXEC_NAME $OBJ_FOLDER/*.o
|
||||
|
@ -9,6 +9,12 @@ void init()
|
||||
{
|
||||
// pc is set using 0xFFFC
|
||||
pc = read_word(0xFFFC);
|
||||
|
||||
write_mem(0xD010, 'T');
|
||||
write_mem(0xD010, 'E');
|
||||
write_mem(0xD010, 'S');
|
||||
write_mem(0xD010, 'T');
|
||||
write_mem(0xD010, 'S');
|
||||
}
|
||||
|
||||
void fetch()
|
||||
@ -32,12 +38,11 @@ void decode()
|
||||
opcode_in_list = ir;
|
||||
opcode_in_table = aaacc;
|
||||
|
||||
|
||||
address_mode = bbb;
|
||||
|
||||
if (cc == 0b01)
|
||||
{
|
||||
// correct the addressing mode for '01' opcodetype
|
||||
// correct the addressing mode for '01' opcode type
|
||||
if (bbb == 0b000)
|
||||
{
|
||||
address_mode = indirect_x;
|
||||
|
@ -9,7 +9,7 @@ db x; // x register
|
||||
db y; // y register
|
||||
db sp; // stack pointer
|
||||
db sr; // status register
|
||||
db ir; // intruction register
|
||||
db ir; // instruction register
|
||||
|
||||
enum opcodes_table
|
||||
{ /// aaa00 aaa01 aaa10
|
||||
@ -53,7 +53,7 @@ typedef enum address_mode am;
|
||||
|
||||
am address_mode;
|
||||
|
||||
void adc(); // add memory to accumalator with carry
|
||||
void adc(); // add memory to accumulator with carry
|
||||
void and(); // and memory with accumulator
|
||||
void asl(); // shift left one bit (memory or accumulator)
|
||||
void bcc(); // branch on carry clear
|
||||
@ -96,7 +96,7 @@ void plp(); // pull processor status from stack
|
||||
void rol(); // rotate on bit left (memory or accumulator)
|
||||
void ror(); // rotate on bit right (memory or accumulator)
|
||||
void rti(); // return from interrupt
|
||||
void rts(); // retrun from subroutine
|
||||
void rts(); // return from subroutine
|
||||
void sbc(); // subtract memory from accumulator with borrow
|
||||
void sec(); // set carry flag
|
||||
void sed(); // set decimal flag
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setbuf(stdout, NULL);
|
||||
printf("Apple-I Computer\n");
|
||||
|
||||
init(); // start the processor
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "inc/types.h"
|
||||
#include "inc/rom.h"
|
||||
#include "inc/memory.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
|
||||
@ -77,6 +78,11 @@ void write_mem(dw address, db data)
|
||||
// 4KB memory RAM
|
||||
ram_memory[address] = data;
|
||||
}
|
||||
else if (address == 0xD010)
|
||||
{
|
||||
// output character to video
|
||||
printf("%c", data);
|
||||
}
|
||||
|
||||
// any other addressed memory will be ignored on write
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ void fetch_operand()
|
||||
address = read_word(pc);
|
||||
operand = read_byte(address);
|
||||
pc = pc + 2;
|
||||
break;
|
||||
case absolute_x:
|
||||
address = read_word(pc);
|
||||
address = address + x;
|
||||
@ -69,7 +70,7 @@ void fetch_operand()
|
||||
|
||||
void adc()
|
||||
{
|
||||
// add memory to accumalator with carry
|
||||
// add memory to accumulator with carry
|
||||
fetch_operand();
|
||||
ac = ac + operand + C_IS_SET;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user