Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jessica Hawkwell
/
kcpu
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d5f32759
authored
Sep 28, 2017
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slight refactoring, adding new capabilities
1 parent
8aa59d72
Pipeline
#204
failed
in 12 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
16 deletions
src/main/java/me/felinewith/kcpu/KBoard.java
src/main/java/me/felinewith/kcpu/Kcpu.java
src/main/java/me/felinewith/kcpu/memory/BootRom.java
src/main/java/me/felinewith/kcpu/opcodes/OpDirector.java
src/main/java/me/felinewith/kcpu/util/HardwareTask.java → src/main/java/me/felinewith/kcpu/util/HardwareExec.java
src/main/java/me/felinewith/kcpu/util/HardwareMemIrq.java
src/main/java/me/felinewith/kcpu/util/HardwareSendIrq.java
src/main/java/me/felinewith/kcpu/KBoard.java
View file @
d5f3275
...
...
@@ -17,7 +17,8 @@ import me.felinewith.kcpu.hardware.Kmcp;
import
me.felinewith.kcpu.memory.BootRom
;
import
me.felinewith.kcpu.memory.Buffer
;
import
me.felinewith.kcpu.util.BaseDevice
;
import
me.felinewith.kcpu.util.HardwareTask
;
import
me.felinewith.kcpu.util.HardwareExec
;
import
me.felinewith.kcpu.util.HardwareMemIrq
;
/**
*
...
...
@@ -72,7 +73,7 @@ public class KBoard extends BaseDevice implements IMemory {
attachMemory
(
0
,
0xff00
,
new
Buffer
());
attachMemory
(
1
,
0x1000
,
new
BootRom
());
tt
=
new
Hardware
Task
(
devices
[
0
]);
tt
=
new
Hardware
Exec
(
devices
[
0
]);
t
=
new
Timer
(
"CPU Cycler"
);
t
.
schedule
(
tt
,
0
,
1
);
}
...
...
@@ -84,11 +85,12 @@ public class KBoard extends BaseDevice implements IMemory {
else
if
(
dev
<=
0x0f
)
{
short
devOff
=
deviceMaps
[
rdev
].
getOffset
();
short
devAddr
=
(
short
)(
addr
-
devOff
);
devices
[
rdev
].
memIrq
(
devAddr
);
tpe
.
execute
(
new
HardwareMemIrq
(
devices
[
rdev
],
devAddr
)
);
}
else
if
(
0x10
<=
dev
&&
dev
<=
0x1f
)
{
short
devOff
=
memDevMaps
[
rdev
].
getOffset
();
short
devAddr
=
(
short
)(
addr
-
devOff
);
tpe
.
execute
(
new
HardwareMemIrq
(
memDevs
[
rdev
],
devAddr
));
memDevs
[
rdev
].
memIrq
(
devAddr
);
}
...
...
@@ -96,7 +98,7 @@ public class KBoard extends BaseDevice implements IMemory {
@Override
public
void
sendIrq
(
byte
irq
)
{
if
(
irq
>=
16
)
{
return
;
}
if
(
devices
[
irq
]
!=
null
)
{
devices
[
irq
].
exec
(
);
}
if
(
devices
[
irq
]
!=
null
)
{
tpe
.
execute
(
new
HardwareExec
(
devices
[
irq
])
);
}
}
@Override
public
short
length
()
{
return
(
short
)
memory
.
length
;
};
...
...
@@ -133,9 +135,9 @@ public class KBoard extends BaseDevice implements IMemory {
memory
[
addr
]
=
data
;
}
p
rivate
void
attachDevice
(
int
port
,
int
offset
,
IDevice
device
)
{
p
ublic
void
attachDevice
(
int
port
,
int
offset
,
IDevice
device
)
{
attachDevice
(
port
,
(
short
)
offset
,
device
);
}
p
rivate
void
attachDevice
(
int
port
,
short
offset
,
IDevice
device
)
{
p
ublic
void
attachDevice
(
int
port
,
short
offset
,
IDevice
device
)
{
if
(
devices
[
port
]
!=
null
)
{
return
;
}
else
if
(
deviceMaps
[
port
]
!=
null
)
{
return
;
}
...
...
@@ -145,9 +147,9 @@ public class KBoard extends BaseDevice implements IMemory {
device
.
init
(
this
);
}
p
rivate
void
attachMemory
(
int
port
,
int
offset
,
IMemory
device
)
{
p
ublic
void
attachMemory
(
int
port
,
int
offset
,
IMemory
device
)
{
attachMemory
(
port
,
(
short
)
offset
,
device
);
}
p
rivate
void
attachMemory
(
int
port
,
short
offset
,
IMemory
device
)
{
p
ublic
void
attachMemory
(
int
port
,
short
offset
,
IMemory
device
)
{
if
(
memDevs
[
port
]
!=
null
)
{
return
;
}
else
if
(
memDevMaps
[
port
]
!=
null
)
{
return
;
}
...
...
@@ -155,7 +157,7 @@ public class KBoard extends BaseDevice implements IMemory {
memDevMaps
[
port
]
=
new
KMemoryRange
(
offset
,
device
.
length
());
}
p
rivate
short
checkDevice
(
short
addr
)
{
p
ublic
short
checkDevice
(
short
addr
)
{
short
a
;
KMemoryRange
io
;
...
...
src/main/java/me/felinewith/kcpu/Kcpu.java
View file @
d5f3275
...
...
@@ -109,6 +109,12 @@ public class Kcpu extends TimerTask implements IDevice {
short
rd
=
(
short
)(
0x03
&
d
);
switch
(
od
)
{
// ask what device is using which address
case
ASK
:
registers
[
0
]
=
board
.
checkDevice
((
short
)
0
);
case
ASK:
registers
[
0
]
=
board
.
checkDevice
((
short
)
0
);
case
ASK:
registers
[
0
]
=
board
.
checkDevice
((
short
)
0
);
case
ASK:
registers
[
0
]
=
board
.
checkDevice
((
short
)
0
);
// interrupt to port
case
IRQD
:
board
.
sendIrq
((
byte
)
registers
[
0
]);
return
;
case
IRQD_A:
board
.
sendIrq
((
byte
)
MemHelper
.
readShort
(
a
,
board
));
return
;
...
...
src/main/java/me/felinewith/kcpu/memory/BootRom.java
View file @
d5f3275
...
...
@@ -10,7 +10,7 @@ import me.felinewith.kcpu.util.BaseMemory;
public
class
BootRom
extends
BaseMemory
{
public
BootRom
()
{
memory
=
new
byte
[
0x
0fff
];
memory
=
new
byte
[
0x
1000
];
Arrays
.
fill
(
memory
,
(
byte
)
0x75
);
}
...
...
src/main/java/me/felinewith/kcpu/opcodes/OpDirector.java
View file @
d5f3275
...
...
@@ -24,6 +24,26 @@ public enum OpDirector {
MOVAA
(
0x0017
,
Memory
.
class
),
// cpu stuffies
ASK_AA
(
0x1000
,
null
),
ASK_AD
(
0x1001
,
null
),
ASK_AN
(
0x1002
,
null
),
ASK_AR
(
0x1003
,
null
),
ASK_DA
(
0x1004
,
null
),
ASK_DD
(
0x1005
,
null
),
ASK_DN
(
0x1006
,
null
),
ASK_DR
(
0x1007
,
null
),
ASK_NA
(
0x1010
,
null
),
ASK_ND
(
0x1011
,
null
),
ASK_NN
(
0x1012
,
null
),
ASK_NR
(
0x1013
,
null
),
ASK_RA
(
0x1014
,
null
),
ASK_RD
(
0x1015
,
null
),
ASK_RN
(
0x1016
,
null
),
ASK_RR
(
0x1017
,
null
),
IRQM
(
0x8f00
,
null
),
IRQM_R
(
0x8f01
,
null
),
IRQM_D
(
0x8f02
,
null
),
...
...
src/main/java/me/felinewith/kcpu/util/Hardware
Task
.java
→
src/main/java/me/felinewith/kcpu/util/Hardware
Exec
.java
View file @
d5f3275
...
...
@@ -7,15 +7,12 @@ import me.felinewith.kcpu.IDevice;
*
* @author jlhawkwell
*/
public
class
Hardware
Task
extends
TimerTask
{
public
class
Hardware
Exec
extends
TimerTask
{
IDevice
id
;
public
Hardware
Task
(
IDevice
device
)
{
public
Hardware
Exec
(
IDevice
device
)
{
id
=
device
;
}
@Override
public
void
run
()
{
id
.
exec
();
}
@Override
public
void
run
()
{
id
.
exec
();
}
}
src/main/java/me/felinewith/kcpu/util/HardwareMemIrq.java
0 → 100644
View file @
d5f3275
package
me
.
felinewith
.
kcpu
.
util
;
import
java.util.TimerTask
;
import
me.felinewith.kcpu.IMemory
;
/**
*
* @author jlhawkwell
*/
public
class
HardwareMemIrq
extends
TimerTask
{
IMemory
id
;
short
a
;
public
HardwareMemIrq
(
IMemory
device
,
short
addr
)
{
id
=
device
;
a
=
addr
;
}
@Override
public
void
run
()
{
id
.
memIrq
(
a
);
}
}
src/main/java/me/felinewith/kcpu/util/HardwareSendIrq.java
0 → 100644
View file @
d5f3275
package
me
.
felinewith
.
kcpu
.
util
;
import
java.util.TimerTask
;
import
me.felinewith.kcpu.IDevice
;
/**
*
* @author jlhawkwell
*/
public
class
HardwareSendIrq
extends
TimerTask
{
IDevice
id
;
byte
i
;
public
HardwareSendIrq
(
IDevice
device
,
byte
irq
)
{
id
=
device
;
i
=
irq
;
}
@Override
public
void
run
()
{
id
.
sendIrq
(
i
);
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment