Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
3aebb247
Verified
Commit
3aebb247
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: new GB mode in python
parent
d57aa9b9
No related branches found
No related tags found
1 merge request
!36
Support for Python
Pipeline
#3606
passed
1 year ago
Stage: build
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/python/bench.py
+0
-1
0 additions, 1 deletion
examples/python/bench.py
examples/python/pocket.py
+0
-1
0 additions, 1 deletion
examples/python/pocket.py
src/py.rs
+3
-3
3 additions, 3 deletions
src/py.rs
src/python/boytacean/__init__.py
+12
-1
12 additions, 1 deletion
src/python/boytacean/__init__.py
with
15 additions
and
6 deletions
examples/python/bench.py
+
0
−
1
View file @
3aebb247
...
...
@@ -4,7 +4,6 @@ from boytacean import GameBoy, CPU_FREQ
CLOCK_COUNT
=
100000000
gb
=
GameBoy
(
apu_enabled
=
False
,
serial_enabled
=
False
)
gb
.
load
()
gb
.
load_rom
(
"
../../res/roms/demo/pocket.gb
"
)
start
=
time
()
cycles
=
gb
.
clocks
(
CLOCK_COUNT
)
...
...
This diff is collapsed.
Click to expand it.
examples/python/pocket.py
+
0
−
1
View file @
3aebb247
...
...
@@ -4,7 +4,6 @@ from boytacean import GameBoy
FRAME_COUNT
=
12000
gb
=
GameBoy
(
apu_enabled
=
False
,
serial_enabled
=
False
)
gb
.
load
()
gb
.
load_rom
(
"
../../res/roms/demo/pocket.gb
"
)
start
=
time
()
for
_
in
range
(
FRAME_COUNT
):
...
...
This diff is collapsed.
Click to expand it.
src/py.rs
+
3
−
3
View file @
3aebb247
use
pyo3
::{
prelude
::
*
,
types
::
PyBytes
};
use
crate
::{
gb
::
GameBoy
as
GameBoyBase
,
gb
::
{
GameBoy
as
GameBoyBase
,
GameBoyMode
},
ppu
::{
DISPLAY_HEIGHT
,
DISPLAY_WIDTH
},
};
...
...
@@ -13,9 +13,9 @@ struct GameBoy {
#[pymethods]
impl
GameBoy
{
#[new]
fn
new
()
->
Self
{
fn
new
(
mode
:
u8
)
->
Self
{
Self
{
system
:
GameBoyBase
::
new
(
None
),
system
:
GameBoyBase
::
new
(
Some
(
GameBoyMode
::
from_u8
(
mode
))
),
}
}
...
...
This diff is collapsed.
Click to expand it.
src/python/boytacean/__init__.py
+
12
−
1
View file @
3aebb247
from
enum
import
Enum
from
PIL.Image
import
Image
,
frombytes
from
.boytacean
import
DISPLAY_WIDTH
,
DISPLAY_HEIGHT
,
CPU_FREQ
,
GameBoy
as
GameBoyRust
class
GameBoyMode
(
Enum
):
DMG
=
1
CGB
=
2
SGB
=
3
class
GameBoy
:
def
__init__
(
self
,
mode
=
GameBoyMode
.
DMG
,
ppu_enabled
=
True
,
apu_enabled
=
True
,
dma_enabled
=
True
,
timer_enabled
=
True
,
serial_enabled
=
True
,
load
=
True
,
):
super
().
__init__
()
self
.
_system
=
GameBoyRust
()
self
.
_system
=
GameBoyRust
(
mode
.
value
)
self
.
_system
.
set_ppu_enabled
(
ppu_enabled
)
self
.
_system
.
set_apu_enabled
(
apu_enabled
)
self
.
_system
.
set_dma_enabled
(
dma_enabled
)
self
.
_system
.
set_timer_enabled
(
timer_enabled
)
self
.
_system
.
set_serial_enabled
(
serial_enabled
)
if
load
:
self
.
load
()
def
load
(
self
):
self
.
_system
.
load
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment